Gridview rowupdating neweditindex

Rated 3.95/5 based on 912 customer reviews

These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.I am using Template Field’s Item Template and Edit Item Template for providing read only and editing interface of the same column in the Grid View.To do this we first need to obtain the reference of the current row by using its index no as shown in the first line below.

In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: For brevity I am not storing connection string in the web.config and also not using any Data Access Component.To get what you've type in I think you need to get the new values (the Dictionary e. In your case you can use it something like this (assuming name, phone and email are what they're called in your gridview): NOTE: If you're simply using this to get the values typed in to update your database then you're better of binding the datagrid and use the value after that to ensure you definitely have the same values in the datagrid as to what you put into the database.Alternatively, use the Row Updated event instead of the Row Updating event. However, as Martin says you don't need to do this if all you're doing is simply getting the new values put in your data grid to then update your database.For example, the current data is: name: Blake, phone: 123-234-3456, email: [email protected], contact Id: 22 I type in new data: name: John, phone: 555-555-5555, email: [email protected], contact Id: 22 Data that ends up in the database: name: Blake, phone: 123-234-3456, email: [email protected], contact Id: 22 When you raise the Row Updating event your basically getting the values BEFORE the Grid View updates the row.This is basically so you can cancel the update operation.

Leave a Reply