Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > SQL row numbering
 

SQL row numbering

I need to put row numbering in SQL Select but not in every row. For exemple, I need to get samting like this:

RowEmployeeId EmployeeName Order
-------------------------------------------
1 1002 Alden 400
1002 Alden 450
2 2343 Lawson 450
2343 Lawson 480


How can I do it? Is it possible?


Nensy V.
Nensy V_  Tuesday, July 14, 2009 12:13 PM
Hi Nensy,

It looks like the data you want to display in a DataGridView come from two tables with a parent/child relation in the DataBase, right? It's not common to display data from the parent and child tables in a DataGridView in the way you show.

If the value under the Row column in the DataGridView doesn't come from DataBase, you can use mix-mode in the DataGridView, i.e. bind the DataGridView to a data source, e.g. a DataTable that contains the EmployeeId, EmployeeName and Order and set the cell value under the Row column manually. If the DataGridView support sorting, you need to implement virtual mode for the DataGridView to maintain the unbound data in the DataGridView.

Fore more information on virtual mode in DataGridView, please refer to the following MSDN document:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.virtualmode(VS.80).aspx

Hope this helps.

Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Monday, July 20, 2009 7:00 AM
Not sure I understand the question.

Are you trying to store the data in your database in this way?

Or populate a DataGridView control?
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Tuesday, July 14, 2009 7:13 PM

I won’t to storethe data in my database that way.


I wish to get SQL Select so I can populate a DataGrid.


Nensy V.
Nensy V_  Wednesday, July 15, 2009 6:07 AM
Hi Nensy,

It looks like the data you want to display in a DataGridView come from two tables with a parent/child relation in the DataBase, right? It's not common to display data from the parent and child tables in a DataGridView in the way you show.

If the value under the Row column in the DataGridView doesn't come from DataBase, you can use mix-mode in the DataGridView, i.e. bind the DataGridView to a data source, e.g. a DataTable that contains the EmployeeId, EmployeeName and Order and set the cell value under the Row column manually. If the DataGridView support sorting, you need to implement virtual mode for the DataGridView to maintain the unbound data in the DataGridView.

Fore more information on virtual mode in DataGridView, please refer to the following MSDN document:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.virtualmode(VS.80).aspx

Hope this helps.

Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Monday, July 20, 2009 7:00 AM

You can use google to search for other answers

Custom Search

More Threads

• Parameterized queries
• How can I set null value to DateTime column in Typed DataSets (Visual Studio 2005)
• Binding an ArrayList to a DataGridView
• Data grid Problem Master/Detail update
• Testing FindBy Method for returned Null
• Cannot Set properties for controls that are not visible
• How to change a row wihtin a grid
• Deleting rows in Winforms Datagrid
• Using SortedList and/or sortedDictionary with DataGridView
• Cannot change row selection after drag and drop re-ordering of rows