Nakedcam - Commandfield rowupdating

While the default editing and inserting interfaces for the Bound Field and Check Box Field can be helpful, the interface lacks any sort of validation.

If a user makes a data entry mistake - such as omitting the (such as -50) an exception will be raised from within the depths of the application architecture.

It is this value that is compared against a Required Field Validator.

Now, you can easily set the Required Field Validator's Initial Value property to "Select an item" or whatever your text was which means that you cannot leave the control whose value or text property is "Select an item" or the text set by you.

Since the Drop Down List is in the Item Template of the Grid View control so I placed the Required Field Validator inside the Item Template right beneath the Drop Down List control.

It is a common scenario that you want the first item of the Drop Down List to be some message saying "Please select an item".

You will also notice that when you loose focus from the control the validation control event will be fired.

This is because the validation controls have a property "Enable Client Script" which means that the validation will be fired on the client side first and then on the server side. Validate does not occur then no validation will be fired.

The Required Field Validator for the Text Box control in the Description column is placed in the Edit Item Template of the Grid View control.

This is because the Text Box is in the Edit Item Template and that is what we need to validate.

Have you tried setting the values when the gridview row command event is called?

Tags: , ,