I am having some problems using win grid. Following is my scanrio.
I have a data gird bound with a bindingsource.
On row update, I need to fetch the row data before it was updated . I tried to catch BeforeRowUpdate(sender,e) event. It gives me new values. If I try to get value from dataset against e.Row.Index (index of row passed to BeforeRowUpdate event), it again gives me the new value entered in the gird cell.
Kindly help me out with this. I am stuck in the middle of no where because of this problem.
Thanks in advance,
Thank you so much for your reply Mike.
I have checked. UpdateMode property of wingrid is already set to OnRowChangeOrLostFocus. I have also tried changing it to OnRowChange. In both cases when I capture BeforeRowUpdate() event of grid, values in dataset are updated. I was thinking about getting the data again from database but it is not a workable solution because changing a row more than once without saving to database will cause problems.
I have also tried dropping a new grid so that may be I have chaged some property while attampting to get previous value. It shows the same behaviour. Am I missing somethig else?
You help is highly appreciated and acknowledged.
Hi,
The grid updates the data source based on the UpdateMode property. By default, it's set to OnCellChangeOrLostFocus. If you change this to OnRowChangeOrLostFocus, then you should be able to get the values from the underlying data source.
Also, it's not a good idea to use the Index of the row to get the underlying data row. The rows in the grid might be filtered or sorted and so the indices would be incorrect. What you should do is use row.ListObject to get the actual data object underlying the row.