We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding Rows To GridDataBoundGrid

Hello,

How Can I through code add new record to DataBoundGrid. Grid has EnableAddNew = true.
Adding new rows is to be prohibited until some key is pressed. I tried

this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.Binder.AddNew();
this.gridDataBoundGrid1.EndUpdate();

But no record is added.

Thank you for your help.

Regards,
MS

3 Replies

AD Administrator Syncfusion Team July 31, 2006 11:23 AM UTC


Hi Marek,

The GridDataBoundGrid doesn''t holds any data of its own as it shows the data from the underlying datasource.
So, to add a new record to the GridDataBoundGrid, you need to add the record to underlying datatable to reflect the changes in the grid.
Please refer the sample attached.

Thanks,
Srividhya R

GDBGAddRow.zip


MS Marek Solarski August 3, 2006 01:39 PM UTC

Hi Srividhya,

Thank you for your answer.

If I need to add records to the underlying datasource I must have some values. But I''d like the user to enter then. How can I allow user entering new values? I want enableAddNew to be set to false in order to avoid two empty records(entered by user and the second empty).

Is there posibility to add new record not at the bottom of the grid but in the middle?

Regards,
Marek


AD Administrator Syncfusion Team August 4, 2006 05:13 AM UTC

Hi Marek,

The GridDataBoundGrid only displays what is presented to it by its datasource. So, if you want to add a row in the middle of the grid, then you would have to some how add a row in the middle of your datasource.

If the datasource is a DataTable, then you could try calling datatable1.NewRow to get a new row, populate it the way you want, call datatable1.Rows.InsertAt to insert the row and then call datatable1.AcceptChanges to make the new row appear where you inserted it. But, there is no way to do this directly from the grid.

Thanks,
Srividhya.

Loader.
Live Chat Icon For mobile
Up arrow icon