Gridview rowupdating code in asp net

In data driven web sites, users are normally allowed to view data and administrators are allowed to add, edit or delete data.

In this tutorial I will show you how you can create an editable Grid View control for administrators to modify database records directly into the Grid View control.

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

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.

Next event is the Grid View Row Editing event to give ASP. You need to set the Edit Index property of the Grid View with the New Edit Index property of the Grid View Edit Event Args class.

If user clicks the Cancel button while Grid View is in editing mode, you need to Cancel the Editing process and also need to reset the Edit Index property to -1 in the Row Canceling Edit event of the Grid View control as shown below: The last step is to handle the Row Updating event to actually update the back end database.

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.

Search for gridview rowupdating code in asp net:

gridview rowupdating code in asp net-52gridview rowupdating code in asp net-69gridview rowupdating code in asp net-25gridview rowupdating code in asp net-61

In the above code, I set two properties Show Edit Button and Show Cancel Button of Command Field.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “gridview rowupdating code in asp net”

  1. Clair 9780863394171 0863394175 The Welfare State - A Suitable Case for Treatment, Duncan Watts 9780441862900 044186290X Vickers, Mick Farren 9780853111405 0853111405 A Demo Tokamak Reactor - Aspects of the Conceptual Design, Great Britain 9780387966434 0387966439 An APL Compiler, Timothy Budd 9780851622460 0851622461 Buy a Band: "Spring" from the Four Seasons, Vivaldi 9781903712009 1903712009 Declaration of Helsinki 2000, David Hutchinson 9780852498361 0852498365 Musica Britannica, v.