Gridview rowupdating cancel update
For demonstration I have created a database (named Database.mdf) in which we have a table named tbl_Employee.
If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google , Twitter, Linkedin and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox .
Here we can update Name, Emp_Code and Emp_Age fields depending on the Id field of the "EMPLOYEE" table.
However, most of the real world cases call for validating the data being edited or deleted. Drag and drop an SQL Data Source control on the web form.
There can be several approaches taken for validating data. For our example we are going to use Customers table of Northwind database. Open its smart tag and choose "Configure Data Source" option to start Configure Data Source wizard.
Delete a Record We can delete a record from the database table by clicking on the delete button that is in the Delete column of the Grid View.
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.