Asp net gridview rowupdating datakey

So once after done with editing data, if we click update the following method will be triggered. Once we access the required fields in the code behind, we need to update the data in the database and show the updated data to the user. If the user clicks the Delete button On Row Deleting event will be fired. Going into that code we are trying to get the primary key of the employee table(Employee ID) by using Grid View Data Key Names and then This entry was posted on March 27, 2009 at am and is filed under ASP.

So am calling the method Bind Grid Data method which is overloaded .

Ok let’s move on to Code behind what we have to do when user clicks Edit, Delete, Update and Cancel When we click on Edit the On Row Editing event will be fired.

You can see the C# code below will give the row number whatever you are editing by New Edit Index property.

Secondly if you want to include a custom field (some button or link) in the same column it’s not possible.

If we use proper command names for the buttons like “EDIT”, “DELETE”, “UPDATE”, “CANCEL” these will also trigger the appropriate Grid View Events.

The secret lies in the event handlers–in this case, the Row Updating event handler. Grid View Update Event Args object that is passed in. This page contains copyright material from //blog.and you have no rights to copy and paste the full text into your own blog even if you have written permission to the contrary.

By default, the Grid View control doesn’t have support for inserting new records.If he clicks edit (or) in the edit mode he can be able to see the Textbox.The above piece of code will also do the same as label in Item Template and Textbox in the Edit Item Template.So Grid View will put the appropriate row into the Edit Mode by assigning row number to its Edit Index property. You can follow any responses to this entry through the RSS 2.0 feed.Then again we have to call that Bind Grid Data () method to bind data for the textboxes. You can leave a response, or trackback from your own site.

Leave a Reply