Gridview rowupdating event
Here we can update Name, Emp_Code and Emp_Age fields depending on the Id field of the "EMPLOYEE" table.
By combining these controls, you can easily set up master-detail views using very little code and sometimes no code at [email protected] Well, it's calling the code behind method every time. However you should pay attention to the implementation of the method. In my approach, you can leave the commandfield as is, then you can hide it as needed via code behind.If it is expensive, this could easily sum up to a large cost. In this example, I am hiding it if the field "Scenario" of the grid shows the text "Actual" for the relevant row of the Row Data Bound event.With this Grid View control, you could display an entire collection of data, easily add sorting and paging, and perform inline editing.In addition to just displaying data, the Grid View can be used to edit and delete the displayed data as well.The Category ID and Category Name are the Bound columns which are bound to the "Category ID" and "Category Name" fields in the Categories table in Northwind Database.
The "Description" and "Choose" columns are template columns.
From the following chapters you can see some important operations in ASP.
Net Grid View control with simple Data Set or Data Table, and also explains the methods like Insert, Edit, Update and Delete function in the Grid View control.
We first of all create a Stored Procedure that gets the Id of an employee as a parameter from the Grid View on whichever row the user clicked. In this event, first we get the datakey value that is the id of an employee of whichever row the user clicked and that id is passed as a parameter to the Stored Procedure. According to the above, in these three operations we use three events of the Grid View for each operation.
The idea is to only allow a command to be performed on specific people. I'd prefer a declarative solution to a procedural one. For me converting the commandfield to a templatefield control is not an option, as the commandfield comes with built-in functionality that I would otherwise have to create myself, for example the fact that it changes to "Update Cancel" when Edit is clicked, and that when Edit is clicked, all the cells in the row which are labels become textboxes, etc.
I will also show you that how you can use validation against the Drop Down List control which is contained inside the Grid View control.