It seems that the UpdateRowBatch event is called once for each row in a WebGrid that is updated, instead of once for a "batch" of updated rows as its name suggests...
how does this different from the UpdateRow event besides losing cursor focus of an updated row does not trigger a postback?
If I want to handle ALL of the row updates at once, and walk through the grid rows using:
if WedGrid.DataChanged = WebGrid.Modified then
what are my options here?
Should I just handle this in the page_load even and check for Page.IsPostBack?
Thanks,Mike
mccamike said:It seems that the UpdateRowBatch event is called once for each row in a WebGrid that is updated, instead of once for a "batch" of updated rows as its name suggests...
mccamike said:how does this different from the UpdateRow event besides losing cursor focus of an updated row does not trigger a postback?
This means that you don't need to manually "walk" through the grid rows. You'll get one instance of UpdateRowBatch (or UpdateRow) for every row that was updated since the previous postback, and you'll get a reference to that row in the "e.Row" parameter. (This includes rows that were added and modified since the last postback, so checking whether the row is "Added" or "Modified" may still be useful.)
There's one additional event you may want to use when using the grid's batch events: UpdateGrid. This event is raised once after all AddRow, UpdateRow, UpdateCell, and/or DeleteRow events (or their "batch" equivalents) are finished. For instance, if you want to re-bind your grid to be certain that it reflects what's in your data source, you want to do this in UpdateGrid, since doing so in UpdateRowBatch could interfere with the update process.
Ah, very cool... UpdateGrid. Thanks much for the input... we're passing whole DataTables worth of data back to SQL Server here and I need to build a table based on all changed values in the grid, so having UpdateRowBatch called mulitple times is not really what I was looking for... I'll give UpdateGrid a shot.
I HONESTLY beg your pardon... I have been reading up quite a bit - but am still unsure... Please excuse.
Am I right in understanding that for multiple row updates on ultrawebgrid with paging enabled with code
UltraWebGrid.DisplayLayout.LoadOnDemand =
LoadOnDemand.Automatic;
you will have to use UpdateRowBatch and UpdateRowBatch will cause a postback?
Is there any way you can do multiple row updates without a postback for each modified row? Using version 8.3....
Is it possible to do the following: allow multiple row updates and when user either clicks on a Save Button or clicks on another Page number, loop through visible rows in the grid - figure out if there was a change and modify data in a session dataset?
Basically, what I am avoiding here is a postback on every row change... And updating my session dataset once per page rather than once per row change!
For somebody who is half way across the world, a postback is slow....and painful...
Thanks..
UpdateRowBatch will be triggered after each post back if grid founds any modified row. This is triggered for each modified row. In this event you can check modification using e.Row.DataChanged in following way.
protected void UltraWebGrid1_UpdateRowBatch(object sender, RowEventArgs e)
{
if (e.Row.DataChanged == DataChanged.Added)
return;
}
This mode gives best result when you need to change many rows at client and then need to submit the changes to server using some external event like Save button click.
If you want to add new rows in this mode then use of client side row add would be best way. You can set default values client side also. It will save a server trip.
Vince, thanks for explaining UpdateGrid. I am doing something similar. However, I am receiving unexpected results. When I press the "Add" button to add an empty row to the WebGrid it fires the AddRow event (which is expected) and fires the UpdateRowBatch event (which is not expected). I am utilizing the AddRow event to set default values for some of the columns. What I don't understand is why the UpdateRowBatch event is firing and if it is working as described then what can I check in the UpdateRowBatch event to return without doing anything when an empty row is added?
In that case, the approach I suggest is to use UpdateRowBatch to build (one DataRow at a time) the list of data you want to update. Then, in UpdateGrid, you can pass those updates back to the database. It's more efficient than looping through the grid yourself.