In this article I will explain how to edit master-detail form using Grid View and Details View control in ASP.NET Download source code Introduction In one of my previous article I explained…Next event is the Grid View Row Editing event to give ASP. You need to set the Edit Index property of the Grid View with the New Edit Index property of the Grid View Edit Event Args class.If user clicks the Cancel button while Grid View is in editing mode, you need to Cancel the Editing process and also need to reset the Edit Index property to -1 in the Row Canceling Edit event of the Grid View control as shown below: The last step is to handle the Row Updating event to actually update the back end database.In this tutorial we are searching for our Text Box controls txt Product Name and txt Unit Price.To get the Primary Key reference we can use the Data Keys collection of the Grid View.Please keep in mind that there are many different ways to update the database using the Grid View control depending on the type of data you are updating and the functionality the user need and there are many solutions to achieve the same end result.
I have tried to add an event handler to the Row Updated event of my custom control but it is not called.For example a Sql Data Source, which is automatically added to your Web Form if you drag-n-drop your way around Visual Studio 2005.The problem is, I’d very much like to do so, if ASP. But I can’t set a Data Source property or anything on the Sql Data Source!!! I probably have to read the cells on the Grid View of the selected row, find the controls, get the values from those and insert those into my Data Set.This collection only requires the row index no and it will give us the primary key.Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.