Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
UpdateRow after XmlHttpRequest
posted

I am using Infragistics ASP.NET 2007 Volume 1.

I have a grid with XML load on demand that goes through the following sequence:

  1. User updates cell.  AfterExitEditMode client event handler is called.
  2. Event handler calls grid.invokeXmlHttpRequest
  3. Server side handler for XmlHttpRequest makes a database call and returns some values, which are passed back to the client.  At this point I also update the underlying datasource for the grid with the values.
  4. Client Side XmlHttpResponseReceived takes returned values and calls setValue() on a number of cells.

I also have an UpdateRow handler server-side.  This handler uses the e.Row.Cells collection to update the underlying DataSource and then commit the changes to the database.

When these two processes are completed in two distinct AJAX callback contexts, everything works fine.  The client grid values are updated via the first process in one AJAX callback, the user takes focus off the current row, and the UpdateRow handler is fired with a second AJAX callback and the e.Row.Cells collection has the updated values from the first process and commits them to the database accurately.

My problem occurs when both processes are done within the same AJAX callback context.  In other words, the user updates the initial cell and then triggers the entire process by taking focus off the active row.  In this scenario, the following occurs:

  1. AfterExitEditMode handler is called, XmlHttpRequest is made.
  2. Server handles XmlHttpRequest, retrieves new values, returns values to client, updates underlying datasource for grid.
  3. Client handles XmlHttpResponse, calls setValue() on the cells.
  4. At this point, you can see the correct values briefly appear in the grid on the client side.
  5. Server handles UpdateRow, checks e.Row.Cells collection for values to update the datasource for the grid.  These values are not correct.  They still preserve the old values in the grid that were replaced by the XmlHttpResponse handler calling setValue().
  6. Database is updated with the incorrect values.
  7. Client grid is re-bound with the incorrect values.

I've attempted to create a work-around by setting a Session variable to track if both the XmlHttpRequest handler and the UpdateRow handler are called within the same AJAX callback context.  If so, I bypass the updating in Step #5 above using the e.Row.Cells collection and simply save my underlying DataSource direct to the database (since the values were already updated in Step #2).  This allows the correct values to be saved, but the client grid still rebinds with the incorrect values, even though the underlying datasource clearly has the correct values when set to the .DataSource property of the grid during initialization.

The entire problem/solution boils down to this:  I want to respond to the user updating a cell by retrieving some values from the database, update the grid with these values, and then call UpdateRow to commit the values.  Seems straight-forward, but maddening to implement given the substandard documentation and examples for a complex set of controls.  Can somebody please provide guidance?