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

Dynamically calculating a value in a databound grid

Hello, I have a master-detail grid form. In the detail grid, there are two columns, QtyPer and UnitQty. The product of these values is QtyReq. Here''s what I would like to do: Whenever the user changes the values of QtyPer or UnitQty, I''d like to recalculate the value of QtyReq and refresh it in its cell. How do I do this? Thank you.

3 Replies

AD Administrator Syncfusion Team April 4, 2005 02:51 PM

Is QtyReq an Expression column in your DataTable? That would be the simplest way to do it. Otherwise, you could try handling an event like CurrentCellAcceptedChanges and if grid.Currentcell.ColIndex points to one of the first two columns, reset the value in the QtyReq column.


HE Helmut April 6, 2005 08:08 AM

I''m not sure how to set an expression column. However, what is the syntax to set the value of the QtyReq cell of the current row? Thank you. >Is QtyReq an Expression column in your DataTable? That would be the simplest way to do it. > >Otherwise, you could try handling an event like CurrentCellAcceptedChanges and if grid.Currentcell.ColIndex points to one of the first two columns, reset the value in the QtyReq column.


AD Administrator Syncfusion Team April 6, 2005 09:02 AM

One way to do it is to use the CurrencyManager to access the underlying DataRowView and set the value there. CurrencyManager cm = (CurrencyManager)grid.BindingContext[grid.DataSource, grid.DataMember]; DataView dv = (DataView) cm.List; DataRowView drv = (DataRowView) cm.Current; drv["Qty"] = ???? But if you want to use an expression column, here is a sample. http://www.syncfusion.com/Support/user/uploads/GDBG_masterdetails_9a42cfe0.zip

Loader.
Live Chat Icon For mobile
Up arrow icon