I may be wrong in how to manually save data here, as I'm learning how to work with a Batch grid. If so, please correct me...
I have a RadGrid in Batch mode. When the user has made all changes to the header textboxes at the top of the form, and the detail values in the RadGrid below them, the user needs to click a general Save button to save all the data to the DB. (I'm hiding the "Save changes" button in the grid.)
When the Save button is clicked, I execute this javascript...
function
SavePO() {
var
grd = GetControlRAD(
"grdPODetails"
);
grd.get_batchEditingManager().saveChanges(grd.get_masterTableView());
}
As I understand it, that does nothing to the underlying data. Instead, it calls the server-side grdPODetails_BatchEditCommand, at which point I manually update the data. In there, I'm updating the dataset that was initially loaded onto the page behind the scenes...
Protected
Sub
grdPODetails_BatchEditCommand(sender
As
Object
, e
As
Telerik.Web.UI.GridBatchEditingEventArgs)
Handles
grdPODetails.BatchEditCommand
Try
For
Each
command
As
GridBatchEditingCommand
In
e.Commands
Select
Case
command.Type
' Code to delete, insert, or update each row of underlying dataset from HashTables
End
Select
Next
' If no errors, also update header data from controls, then save it all to the DB
Catch
ex as Exception
' TODO - What do I do here?
End
Try
End
Sub
As you can see from my TODO, I'm unsure what to do if there's an error. Do I to put "e.Canceled = True", and if so, what does it do? Also, how can I tell the user what the error (ex.Message) is without a postback? (Or does this auto postback?) Assuming it doesn't postback, the best I can determine is to have a control on the form to write the error to in red font, but management doesn't like that idea. They'd rather I pop up an alert, but not sure that's possible.
Any suggestions? And am I going about this the right way to manually save the data?