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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting row values when adding in GDBG

Thread ID:





91165 Nov 6,2009 09:09 PM UTC Nov 10,2009 09:25 AM UTC WinForms 3
Tags: GridControl
Administrator [Syncfusion]
Asked On November 6, 2009 09:09 PM UTC

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 06:49 AM UTC

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.


Administrator [Syncfusion]
Replied On November 9, 2009 03:59 PM UTC


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.


Dave Taylor

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

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.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon