Hi,
Is it possible to add new row to a datagrid control once it is bound to the data source?
If so, can anyone tell me how to do it?
Thanks,
Printable View
Hi,
Is it possible to add new row to a datagrid control once it is bound to the data source?
If so, can anyone tell me how to do it?
Thanks,
Hi,
Its possible to add a row...
U create a datatable.let it be DtTable.
I hope u use a dataset let it be DtSet.
Let the datagrid be DgDetails
[B]then use this code on click of the add button[/B]
DtTable = DtSet.Tables["Your Table Name"];
DtTable.Rows.Add(DtTable.NewRow());
DgDetails.DataSource = DtTable;
DgDetails.DataBind();
[B]The concept is:[/B]
1) Create a datatable and bind the dataset
2) Add a new row to the datatable
3) Then bind the dataTable to the datagrid.
Hope u got it???
Cheers
----------
Siva
-----------
[COLOR="Olive"]No one is born Genius[/COLOR]
But some error occurs...line no:29
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 27: {
Line 28: table = ds.Tables["Customer"];
Line 29: table.Rows.Add(table.NewRow());
Line 30: dgrid.DataSource = table;
Line 31: dgrid.DataBind();