Range Validation in an EditItemTemplate

Discussion in 'ASP .Net' started by tshad, Feb 7, 2005.

  1. tshad

    tshad Guest

    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
     
    tshad, Feb 7, 2005
    #1
    1. Advertising

  2. tshad

    Peter Blum Guest

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "tshad" <> wrote in message
    news:...
    > 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
    >
     
    Peter Blum, Feb 7, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=
    Replies:
    1
    Views:
    636
    Ashish M Bhonkiya
    May 18, 2004
  2. Replies:
    46
    Views:
    971
    Antoon Pardon
    Jul 25, 2006
  3. Lambda
    Replies:
    2
    Views:
    399
    James Kanze
    Jul 16, 2008
  4. Tomoyuki Kosimizu

    Range does not take an Range object.

    Tomoyuki Kosimizu, Nov 25, 2003, in forum: Ruby
    Replies:
    3
    Views:
    153
    Tomoyuki Kosimizu
    Nov 27, 2003
  5. David Bird
    Replies:
    1
    Views:
    212
    Tiago Macedo
    Jun 23, 2008
Loading...

Share This Page