Rowupdating event in gridview in asp net c

by  |  22-Jun-2016 05:05

By Default, Grid View control displays Item Template which directly shows the Product Name and Unit Price columns but when user clicks Edit button Grid View automatically switches to Edit Item Template and display the control available inside Edit Item Template for user editing.

Now I will show you the C# code behind file of the above ASP.

Data Bind() End Sub Protected Sub Grid View1_Row Updating(By Val sender As Object, By Val e As Grid View Update Event Args) Dim idd As Integer = Convert.

Save all or press "Ctrl S" and hit "F5" to run the page, the page will look as in the following image: Click on "Edit the Grid View", it will display Textboxes in each cell as in the following image: Edit the value(s) here and click on the Update link, it will update all the data or to remove it click on the "Delete" link above the image shown.

One note will be helpful for you, while describing Columns in Grid View if you are using a boundfield then create objects of the control using cells[index] in the rowupdateing event of Grid View, but if you are using controls itself like Label or textboxes etc then use Fincontrol("stringid").

In this tutorial we are searching for our Text Box controls txt Product Name and txt Unit Price.

To get the Primary Key reference we can use the Data Keys collection of the Grid View.

NET page that will handle different Grid View events to provide complete editing functionality.

Community Discussion