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.
Unfortunately, activation email could not send to your email. Please try again.

Adding Rows To GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

47148 Jul 28,2006 09:44 AM Aug 4,2006 01:13 AM Windows Forms 3
loading
Tags: GridControl
Marek Solarski
Asked On July 28, 2006 09:44 AM

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

Administrator [Syncfusion]
Replied On July 31, 2006 07:23 AM


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

Marek Solarski
Replied On August 3, 2006 09:39 AM

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

Administrator [Syncfusion]
Replied On August 4, 2006 01:13 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;