Click here to Skip to main content
16,023,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can any one share code for adding a blank row to a GridView? I want to add a blank row to the top of the grid, i.e., on index[0].

Thanks in advance.
Posted
Updated 31-Mar-10 9:56am
v4

I would say the easiest way is to add an empty record to the datasource before it is bound to the grid.

You may be able to handle the databound event and add a row.
 
Share this answer
 
Is the GridView databound? If so, insert a row to the underlying table.

DataTable dt ...

DataRow newRow = dt.NewRow();
// set row fields
dt[0] = "whatever";

dt.Rows.InsertAt(0, newRow);

myDataGrid.DataSource = dt;
 
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