6 Answers, 1 is accepted
You can use the dedicated BatchEditCommand event handler or the ItemCommand event handler by checking for this condition:
if (e.CommandName == RadGrid.BatchEditCommandName) { ... }
Here you are a suitable documentation article Batch Editing Server-side API.
Best Regards,
Rumen
Progress Telerik
Hi Rumen,
Unless I'm missing something (apologies if I am), neither of these options provides what I asked for.
Protected Sub grdSalesReport_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles grdSalesReport.ItemCommand fires for every single change. If twenty rows are changed, the event is fired twenty times.
Protected Sub grdSalesReport_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs) Handles grdSalesReport.BatchEditCommand fires before the update statements are sent to the database. It's an an automatic-update batch-editmode grid as stated above.
I need to run some code after all the updates have been sent.
The SqlDataSource control has an OnUpdated event which raises the Updated event after the SqlDataSource control has completed an update operation. You can find more on this at MSDN: https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.sqldatasourceview.onupdated?view=netframework-4.7.2.
Best regards,
Rumen
Progress Telerik
Again, I don't think this is what I'm asking for. From the doc:
Raises the Updated event after the SqlDataSource control has completed an update operation.
What I asked for:
I need to run some code after all the updates have been sent.
It has become clear that you would like to use an event that fires only once after all the records have been updated. RadGrid has it's DataBound event which fires only when the data is bound to it. Since editing/inserting/updating items requires the grid to rebind, this event would be the perfect one for your scenario. The only problem is that there is no built-in property or method to understand whether a Batch Editing was done or not, but it's very simple to implement.
For example, you can use the BatchEditCommand which is fired once before any update. At this point you can set a flag that will indicate the reason for the postback. Once all the Updates are finished, data with the changes will be bound to Grid again and so the DataBound event fires. You can use this event in combination with the Flag you have set earlier to identify whether it was an update or not and run the desired logic.
bool
IsBatchCommand =
false
;
// Event raised before an actual Update
protected
void
RadGrid1_BatchEditCommand(
object
sender, GridBatchEditingEventArgs e)
{
IsBatchCommand =
true
;
}
// Event raised after every update is done and data is re-bound to Grid
protected
void
RadGrid1_DataBound(
object
sender, EventArgs e)
{
if
(IsBatchCommand)
{
Label1.Text +=
"<br />RadGrid1_DataBound"
;
}
}
Please let us know if you have any question.
Kind regards,
Attila Antal
Progress Telerik