Asp net gridview rowupdating boundfield

By default when the Grid View controls goes in edit mode, it displays Text Boxes for entering values.You can not attach validation controls directly to these Text Boxes.This way you can attach client side validation controls to the Grid View columns.

The Grid View Update Event Args class has three important collections - Old Values, New Values and Keys.The Ole Values collection contains list of old column values, the New Values collection contains the list of new values entered by the user and the Keys collection contains the list of primary key values as defined by Data Key Names.Make Company Name blank and click on Update button.You should see an error message as shown in Figure 7. NET 2.0 Grid View control allows us to quickly edit and delete records.

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.

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.

Inside the event handler we added two validation conditions: We used the New Values collection to check the entered country.

If the country is null then we set Cancel property of Grid View Update Event Args class to true.

This will convert them from Bound Field to Template Field.