As there is no row at -1 position so Grid View will be shown in normal mode.

When Update link of the Grid View will be clicked (in edit mode), On Row Updating event will fire that will call Update Record method.

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.

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?

Connect me on | https://twitter.com/sheonarayan | Hello....

This article scope is limited to Updating and Deleting records using Grid View and I am not using any readymade Data controls for that but manually writing all event methods.

I will be using Sql objects directly into methods to keep the example simple and straight forward.

That’s why I have placed different templates like Item Template (for normal view) and Edit Item Template (for edit 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. A datakey represents the primary key field or field of a record that can uniquely identify it in a data-bound control. Row Index represents the index of the particular row.Many a times in our applications we use primary keys to get control of the particular record in the gridview. In this method, we have to get changed values of Text Box and Drop Down list and also we need the primary key value for the record that is being edited.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 let’s start with putting the Grid View on page. Data Key Names="Auto ID" Auto Generate Edit Button="True" On Row Editing="Edit Record" On Row Canceling Edit="Cancel Record" On Row Updating="Update Record" Cell Padding="4" Header Style-Horizontal Align="left" On Row Deleting="Delete Record" Row Style-Vertical Align="Top" Fore Color="#333333" Grid Lines="None" In the above code, I have kept Auto Generate Columns as false so that Grid View will not render all the fields of the data source automatically.