Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Updating data via BatchEditCommand then Saving to DB

$
0
0

 

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...

functionSavePO() {
    vargrd = 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...

ProtectedSubgrdPODetails_BatchEditCommand(sender AsObject, e AsTelerik.Web.UI.GridBatchEditingEventArgs) HandlesgrdPODetails.BatchEditCommand
    Try
        ForEachcommand AsGridBatchEditingCommand Ine.Commands
            SelectCasecommand.Type
                ' Code to delete, insert, or update each row of underlying dataset from HashTables
            EndSelect
        Next
        ' If no errors, also update header data from controls, then save it all to the DB
    Catchex as Exception
        ' TODO - What do I do here?
    EndTry
EndSub

 

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?

 


Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>