Validation on controls within a repeater

Discussion in 'ASP .Net Web Controls' started by Octavie, Mar 25, 2005.

  1. Octavie

    Octavie Guest

    Hai there!

    I've build a web user control which contains a repeater control. This
    repeater control has several textboxes which need to be validated. The
    repeater is bound to a dataset that contains a datatable with empty rows.

    The validation I need is to check whether a value has been provided (like
    Required). So, if the datatable has 3 rows, then the repeater shows also 3
    item rows each containing the textboxes.

    How to do the validation on the textboxes?

    Thanxxxxx...
    Octavie

    --
    =====================
    We're allmost at the future! When we get there, we can rest for a while...
    Octavie, Mar 25, 2005
    #1
    1. Advertising

  2. Octavie

    Teemu Keiski Guest

    Hi,

    just place a RequiredFieldValidator inside the same ItemTemplate where
    TextBox to be validated is located (and give it the ID of the TextBox to
    ControlToValidate attribute).

    <%-- repeater item starts here --%>
    <ItemTemplate>
    <asp:TextBox ID="txtInrepeater" runat="server" />
    <asp:RequiredFieldValidator ControlToValidate="txtInrepeater"
    runat="server" ErrorMessage="Input
    required!">*</asp:RequiredFieldValidator>
    </ItemTemplate>
    <%-- repeater item ends here --%>

    This way every TextBox created by binding the repeater aso ahs associated
    RequiredFieldValidator which means that input must be provided for each of
    them.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU

    "Octavie" <> wrote in message
    news:D...
    > Hai there!
    >
    > I've build a web user control which contains a repeater control. This
    > repeater control has several textboxes which need to be validated. The
    > repeater is bound to a dataset that contains a datatable with empty rows.
    >
    > The validation I need is to check whether a value has been provided (like
    > Required). So, if the datatable has 3 rows, then the repeater shows also 3
    > item rows each containing the textboxes.
    >
    > How to do the validation on the textboxes?
    >
    > Thanxxxxx...
    > Octavie
    >
    > --
    > =====================
    > We're allmost at the future! When we get there, we can rest for a while...
    Teemu Keiski, Mar 25, 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. DavidTurcotte

    Unable to access controls within a Repeater

    DavidTurcotte, Dec 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    371
    DavidTurcotte
    Dec 8, 2003
  2. sukanya s via .NET 247

    Javascript Validation for controls within Multipage.

    sukanya s via .NET 247, May 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    548
    Jason DeFontes
    May 8, 2004
  3. Tarun Mistry

    Server controls within a repeater?

    Tarun Mistry, Mar 15, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    486
    Tarun Mistry
    Mar 15, 2006
  4. AC [MVP MOSS]
    Replies:
    2
    Views:
    526
    AC [MVP MOSS]
    Feb 13, 2007
  5. Andy B
    Replies:
    1
    Views:
    981
    bruce barker
    Nov 15, 2008
Loading...

Share This Page