Rowupdating in gridview in c net
Click on the "Advanced" button and check the "Generate INSERT, UPDATE and DELETE statements" checkbox (Figure 3). Now that you have configured the SQL Data Source control let's bind it with a Grid View control. Open its smart tag and configure it as shown in Figure 4.
Here, we set the Data Source of the Grid View to Sql Data Source1. We also enable paging, sorting and editing features of the Grid View.
This tells Grid View that the event handler should be cancelled.
The New Values collection is read/write collection and in the second if condition we set the Country to India. You will find that the data is not accepted by the Grid View.
Set the Control To Validate and Error message properties to the appropriate values. Up till now we used the validation controls to validate Grid View input on client and server side.
These events are raised before updating and deleting the record respectively.Right click on the Grid View and select "End template editing" Run the web form.Click on the Edit button of the Grid View so that it goes into the edit mode.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.On the first step of the wizard click on "New Connection" button to open a dialog as shown in Figure 1.
This way you can attach client side validation controls to the Grid View columns.