Gridview rowupdating event in asp net

6854933580_2c8b688306_z

On the next step select Customer ID, Company Name, Contact Name and Country columns (Figure 2).

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.

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.

You should see an error message as shown in Figure 7.

This will display the template designer for the column as shown in Figure 6.

Note that by default all validation controls validate on the client side.

Right click on the Grid View and select "End template editing" Run the web form.

Next, drag and drop a Required Field Validation control below the Text Box.

Set the Control To Validate property of Required Field Validator control to Text Box1 (i.e. Also, set its Error Message property to "Please enter company name".

Add Grid View1_Row Updating event handler as shown below: The Row Updating event handler receives an event argument of type Grid View Update Event Args.

You must have an account to comment. Please register or login here!