| Author: Pannalal Sinha 07 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
If the datagridview is databound to an underlying datatable then add the new row to the datatable and bind the datagridview again.
DataTable dt=new DataTable();//global declaration
dt=GetDatabaseRecords(); BindGrid(dt);
void BindGrid(DataTable table1) { DataGridView1.DataSource=table1; }
void AddRow() { DataRow dr = dt.NewRow(); dr["id"] = "id"; dr["name"] = "name"; dr["image"] = "image"]; dt.Rows.Add(dr); BindGrid(dt); }
Thanks Panna
|