Click here to Skip to main content
15,868,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can we insert a new record at index 0 in DataGridView using C#.net?
Posted
Updated 18-Apr-11 20:36pm
v2
Comments
walterhevedeich 19-Apr-11 2:34am    
you insert in in the datasource(i.e. datatable) and then rebind.
nsavithal.darsipudi 19-Apr-11 2:37am    
new record should be inserted at index 0th position
Prerak Patel 19-Apr-11 2:48am    
You want it to be inserted manually, I mean in UI? or programatically?
nsavithal.darsipudi 19-Apr-11 3:18am    
manually through winforms controls like textboxes,combobox,radiobuttons
Prasanta_Prince 19-Apr-11 2:51am    
When u bind the datatable or dataview. Just put the value you want to show at top. or Sort in the proper order

Use gridView.Rows.Insert(0, gridviewRow)
 
Share this answer
 
v2
nsavithal.darsipudi: manually through winforms controls like textboxes,combobox,radiobuttons

Use
DataGridView1.Rows.Insert(0, dgvRow)
or
DataGridView1.Rows.Insert(0, values)

Get the values from your user controls in an object array, and then use Rows.Insert
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900