Range Validation in an EditItemTemplate

T

tshad

Can you do Range Validation inside of an EditItemTemplate of the DataGrid?

I have one set up as:

******************************************
<td>
<asp:TextBox Columns="3" id="Weight" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Weight") %>' />
<asp:RangeValidator
ControlToValidate="Weight"
MinimumValue="1"
MaximumValue="10"
Type="Integer"
Text="The Value must be be from 1 to 10!"
runat="server"/>
</td>
***************************************************************

But nothing seems to happen when I push the update button.

It takes whatever value I put in and doesn't seem to check it.

Thanks,

Tom
 
P

Peter Blum

You have done it correctly. The only issues are:
1. The RangeValidator doesn't report an error when the field is empty.
Assign RequiredFieldValidator.
2. The RangeValidator doesn't report an error when the field contains a
value that does not match the Type property, like "abc" is illegal for
Type="integer". Assign a CompareValidator, Operator=DataTypeCheck,
Type=Integer.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top