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.

Setting row values when adding in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

91165 Nov 6,2009 04:09 PM Nov 10,2009 04:25 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 6, 2009 04:09 PM

I have a GridDataBoundGrid control that has its DataSource set to a DataView with a filter "simulation_id = n". Obviously, I don't want to display the simulation_id column, since it is already filtered by this value. How do I intercept the saving of a new row so that I can set this column value? There is a RowSaved event, but this is too late. A "RowSaving" event would be most useful. Thanks
Dave Taylor

Rajadurai C [Syncfusion]
Replied On November 9, 2009 01:49 AM

Hi David,

Thanks for your interest in Syncfusion Products.

With griddataboundgrid binded to datasource and rowfilter applied in, you can set the text to the column which is hidden and by which rowfilter has been applied, while adding, by means of the following code which is handled in a button' Click event in the attached sample.
http://files.syncfusion.com/support/samples/Grid.Windows/7.4.0.15/F91165.zip

Regards,
Rajadurai

Administrator [Syncfusion]
Replied On November 9, 2009 10:59 AM

Rajadurai,

Thanks for the reply, but I think I may not have been precise enough in my question. I want to do this when the user adds a row by using the GDBG's built-in row addition method (i.e. placing the cursor on the last row to add a new record). My first thought was the "RowSaved" event, but this is too late...hence the request for a "RowSaving" event which would make this so much easier, or another work-around.

Thanks

Dave Taylor

Rajadurai C [Syncfusion]
Replied On November 10, 2009 04:25 AM

Hi David,

While adding new row through the addnewrow in griddataboundgrid, you can set the hidden column value by handling the RowLeave event through the following code.

if (e.IsAddNew)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
CurrencyManager cm = grid.BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager;
int pos = grid.Binder.RowIndexToPosition(e.RowIndex);
DataRowView drv = cm.List[pos] as DataRowView;
drv["Department"] = "MECHANICAL";
}

This event get triggerred before RowSaved event get fired.

Here is the modified sample in which the above mentioned code has been implemented.
http://files.syncfusion.com/support/samples/Grid.Windows/7.4.0.15/F91165a.zip

Regards,
Rajadurai

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.

;