To cancel the update operation, set the collections, if necessary, before the values are passed to the data source.
A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source.
Edit Index = -1 'Bind data to the Grid View control. Sql Command Dim sql As String Dim reader As System.
Sql Command Dim sql3 As String Dim reader3 As System.
I'm using a sqldatasource control to populate the grid and want to write the update code in the Row Updating event. I can get the value of the first field using string old_Category = e.
Thanks The OP has clearly mentioned the Row Updated event but if you'd like to suggest Row Updating - a page-level variable should be enough; beyond a postback a View State variable could be advised for the same page.
I will click on the EDIT link in one of the grid view row. I will update the values and click update link in edit mode and edit mode closes. At this point I need to capture the datakey of the updated row into some variable Can someone please help me out with this?
The difference between your code and the code on MSDN is: - The MSDN code takes the new data from the edited row and updates the appropriate data in the To me, this is garbage, because it's so highly coupled to the order of your cells.
If I had written the code, I would explicitly create all the front-end controls and use a binding command (if you aren't familiar, it looks like How should I create all front-end controls in the markup?