In the above code, I set two properties Show Edit Button and Show Cancel Button of Command Field.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.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.To get the Primary Key reference we can use the Data Keys collection of the Grid View.This collection only requires the row index no and it will give us the primary key.
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. Text editor Value = CType(editor, Grid Text Column Editor). Get Column Editor(editable Col) Dim editor Text As String = "unknown" Dim editor Value As Object = Nothing If (Type Of editor Is Grid Text Column Editor) Then editor Text = CType(editor, Grid Text Column Editor). Editing the Grid View control can be an incredibly easy feature to add for certain database tables, especially those who have no foreign key associated and can easily be edited through the use of a standard Text Box web control as shown in the figure below: Before we start examining the ASP.NET Grid View markup and associated code lets first enumerate the important code pieces of this tutorial.