C gridview rowupdating not firing
Now I have declared a Grid View Row variable named row and stored the current row being edited into it.With the help row variable, I am going to find all the controls placed under that row in edit mode using Find Control property.After finding the controls I am using them to pass their values to the parameter of the Sql Command object that is ultimately updating the records into database.After that again, I am doing the same thing that I had done in Cancel Record method, I mean setting Edit Index property of the Grid View to -1 and rebinding the data again by calling Bind Data() method.In practical scenario you should use your existing architecture to populate and update the data.In this article, I am going to take a simple database table that has following fields: Auto ID - Int, Auto Increment, Primary Key Page Name - Varchar(50) Page Description - Varchar(500) Active - Bit(1) In this article, I am not going to explain the workings of Sql objects but focusing on the events and methods of the Grid View that will help us in updating and deleting the records. NET, like how to insert, delete and update record in Grid View control. Here, I’m explaining how to work with Grid View control in ASP.
This will make sure that Bind Data() method will not fire when you are going to edit, update or delete the record.
You may notice that the last column of the Grid View is a Delete column that let user delete the record from database, so I have placed Delete link button inside the tag and have specified on Click property as Java Script confirm return value, so that when user clicks on it he/she sees a confirmation box whether he/she really wants to delete the record.
Till now our Grid View is ready to be populated, now let’s write a method to populate the Grid View.
After successfully deleting records, again I am calling Bind Data() method to rebind the Grid View.
Hope this article helps to begin working with Grid View control. Right now I have a label turn to visible true and a message when someone either edits or deletes something successfully.