Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 757103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:19:24+00:00 2026-05-14T15:19:24+00:00

i have a repeater that is bound to a number of custom dataitems/types on

  • 0

i have a repeater that is bound to a number of custom dataitems/types

on the itemdatabound event for the repeater the code calls a renderedit function that depending on the custom datatype will render a custom control. it will also (if validation flag is set) render a validation control for the appropriate rendered edit control

the edit control overrides the CreateChildControls() method for the custom control adding a number of literalControls thus

protected override void CreateChildControls()
{
    //other bits removed - but it is this 'hidden' control i am trying to validate
    this.Controls.Add(new LiteralControl(string.Format(
                                         "<input type=\"text\" name=\"{0}\" id=\"{0}\" value=\"{1}\" style=\"display:none;\" \">"
                                         , this.UniqueID
                                         , this.MediaId.ToString())
                                         ));
    //some other bits removed
}

the validation control is rendered like this: where the passed in editcontrol is the control instance of which the above createchildcontrols is a method of..

public override Control RenderValidationControl(Control editControl)
{
    Control ctrl = new PlaceHolder();

    RequiredFieldValidator req = new RequiredFieldValidator();
    req.ID = editControl.ClientID + "_validator";
    req.ControlToValidate = editControl.UniqueID;
    req.Display = ValidatorDisplay.Dynamic;
    req.InitialValue = "0";
    req.ErrorMessage = this.Caption + " cannot be blank";
    ctrl.Controls.Add(req);

    return ctrl;
}

the problem is, altho the validation controls .ControlToValidate property is set to the uniqueid of the editcontrol.
when i hit the page i get the following error:
Unable to find control id ‘FieldRepeater$ctl01$ctl00’ referenced by the ‘ControlToValidate’ property of ‘FieldRepeater_ctl01_ctl00_validator’.

i have tried changing the literal in the createchildcontrols to a new TextBox(), and then set the id etc then, but i get a similar problem.

can anyone enlighten me?
is this because of the order the controls are rendered in? ie the validation control is written before the editcontrol?
or…

anyhow any help much appreciated

thanks

nat

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:19:25+00:00Added an answer on May 14, 2026 at 3:19 pm

    You have to use editControl.ID not editControl.UniqueID

    Also take into account that if editControl must be something that can be used with a required field vaidator. It doesn’t make sense this validator for ALL input controls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeater that's bound to a SQL Data Source (using ASP.NET). Are
I have a Repeater control that is being bound to the result of a
I have a Repeater control that loads instances of a custom control I have
I have Repeater Control and in that i have code like this <div runat=server
I have a repeater object that displays a number of rows. I also have
I have a repeater control that's bound to a table in my database. One
I have a repeater control that repeats a DevExpress ASPxGridView for every item bound
I have a repeater that is bound to a List(of T) object collection. It's
I have a repeater that is bound with three values, a visible User Name
I have a .NET repeater control that is data-bound to a List. As part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.