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.
When Delete link of the Grid View will be clicked, it will confirm the user whether they really want to Delete the record, if they will click OK, it will fire On Row Deleting event of the Grid View that will call Delete Record method.
In this method, I am specifying the Edit Index property of the Grid View to -1.
As there is no row at -1 position so Grid View will be shown in normal mode.
In this method again, I am getting the primary key value using Data Keys property of the Grid View and using it to delete the records from the database.
After successfully deleting records, again I am calling Bind Data() method to rebind the Grid View.
You can notice that I have kept Required Field Validator too inside the Edit Item Template as I want the textbox to be validated for empty data.
For demonstration I have created a database (named Database.mdf) in which we have a table named tbl_Employee.I will be using Sql objects directly into methods to keep the example simple and straight forward.In practical scenario you should use your existing architecture to populate and update the data.To get the Primary key, I have used Data Keys property of the Grid View with the index of the row, being edited and stored into a integer variable after parsing.Now I have declared a Grid View Row variable named row and stored the current row being edited into it.For Page Name and Page Description field I want them to appear in the Text Box in edit view, so I have specified text property of Text Box as the field value in Edit Item Template and for Active field, I want it to appear as the Drop Down List so I have specified the Selected Value property as the value of the Active field.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.Connect me on | https://twitter.com/sheonarayan | Hello.... Microsoft is conducting an online survey to understand your opinion of the Msdn Web site.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.If you have a feedback or suggestion, please do write to me. Full Name: Sheo Narayan Member Level: Honorary Platinum Member Status: Administrator Member Since: 7/8/2008 PMCountry: India Regards, Sheo Narayan MVP, Author, Writer, Mentor & architecting applications since year 2001. What would you do if you wanted to have an event trigger when you click on the "cancel" button during the delete process. When a person starts to delete another item and decides to cancel the delete, the old message from the previously edited or deleted item still shows. ya,its how can I use the button field for the edit and delete in the template field.suppose i used that controls,what kind of events could I used for edit successfully?