Vb net gridview rowupdating example


06-Feb-2018 00:59

In case of the bound field’s we need to check what column it is and need to use index of that cloumn, which is little hard and even in future if we change the column order If you see the Last Template Field part in the above code, I am using the link buttons for edit, update, delete and cancel.

May be you may think why am I using link buttons as we are provided with some command field buttons by Grid View.

whether a template field has information of "Command" or "String" so that later data retrieval and data binding of that particular child control will be made accordingly.

A "Command" (Edit, Delete, and Insert) requires instantiation in the Button control while he "String" requires a Label or Text Box.

By default all the boundfields will be trasferred as Textboxes in Edit Mode.

To avoid this we need to keep the property Read Only as false, Then in the edit mode nothing will happenes. The reason I use Template Field instead of Bound Field is that, it is very easy to grab those controls in the codebehind if we user labels or textboxes.

Now, coming to the member methods listed above, there is a constructer which simply sets the aforementioned data members with those passed as parameters. Container's control collection is filled with all controls in which items of each type are instantiated.

The above piece of code will also do the same as label in Item Template and Textbox in the Edit Item Template.Suppose if we are trying to hide primary key of our table, there is actually no need to hide. In the above Snippet you are seeing a label in Item Template that means whenever we are showing Grid View to the user Label will be visible to the user.