Rowupdating in gridview far qc stamping and dating
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.
Other templates used here are Edit Item Template and Footer Template. CREATE PROCEDURE [dbo].[employee_pro] ( @empid as int=0, @name as varchar(50)='', @address as varchar(50)='', @designation as varchar(50)='', @status as varchar(50)='' ) AS BEGIN SET NOCOUNT ON; if(@status = 'Display') begin Select * from employee end else if(@status = 'Add') begin Insert into employee(name,address,designation,createtime) values (@name,@address,@designation,getdate()) end else if(@status = 'Update') begin Update employee set [email protected], [email protected],[email protected] where [email protected] end else if(@status = 'Delete') begin Delete from employee where [email protected] end ENDStored cs using System; using System.
But ensure that the control/link is inside the Grid View, only then can we cast sender as Grid View.
This code is a bit complex but just add it knowing that we may refer to it in the future.
Each column represents a field, while each row represents a record.
The Grid View control supports the following features:use Row Editing, Row Updating, Row Deleting, Row Command, Row Data Bound, Row Canceling Edit, and Pagination in a Data Grid.
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.