CustomValidator in Repeater

Discussion in 'ASP .Net' started by =?Utf-8?B?UmljaGFyZEg=?=, Apr 24, 2006.

  1. Hi,

    I have a Repeater where each row (Repeater item) contains a Checkbox and two
    Textboxes. The first Textbox has a RequiredFieldValidator and everything work
    fine. The other should only validate if the Chekbox is checked. To achieve
    this I've added a CustomValidator, set the ControlToValidate to the id of the
    Textbox and set a OnServerValidate handler. But once the OnServerValidate
    code behind method fires I can't find a good solution on how to find the
    checkbox in that Repeater item.

    Any ideas?

    protected void valReqErrorMessage_ServerValidate(object source,
    ServerValidateEventArgs args)
    {
    //Only validate args.Value if "chb" is selected ... ?
    }

    Thanks in advance

    Richard
    =?Utf-8?B?UmljaGFyZEg=?=, Apr 24, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?UmljaGFyZEg=?=

    camelinckx

    Joined:
    Nov 9, 2006
    Messages:
    3
    Try this,

    The source should be validator, sitting on the RepeaterItem, get to it via the Parent and then find the checkbox control.

    i.e.

    CheckBox checkBox = ((RepeaterItem)((Control)source).Parent).FindControl("chb");

    where "chb" is the id of your checkbox

    Chris.-
    camelinckx, Nov 9, 2006
    #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. Replies:
    0
    Views:
    836
  2. Replies:
    0
    Views:
    2,858
  3. Replies:
    1
    Views:
    7,003
    Karl Seguin
    Aug 10, 2005
  4. uncensored
    Replies:
    0
    Views:
    786
    uncensored
    Oct 25, 2006
  5. David Thielen

    CustomValidator inside Repeater is ignored

    David Thielen, Oct 23, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    653
    David Thielen
    Oct 23, 2006
Loading...

Share This Page