-
Junior Member
Adding new row to DataGrid
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,
-
Junior Member
Re: Adding new row to DataGrid
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
then use this code on click of the add button
DtTable = DtSet.Tables["Your Table Name"];
DtTable.Rows.Add(DtTable.NewRow());
DgDetails.DataSource = DtTable;
DgDetails.DataBind();
The concept is:
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
-----------
No one is born Genius
-
Junior Member
Re: Adding new row to DataGrid
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();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules