Error: Multiple controls with the same ID '1' were found.

Discussion in 'ASP .Net Web Controls' started by vibs, Jan 20, 2006.

  1. vibs

    vibs Guest

    I am getting the following error when dynamically adding
    RequiredFieldvalidator control to a Table.
    Multiple controls with the same ID '1' were found. FindControl requires that
    controls have unique IDs

    I get this error only on validator control and not on labels or textbox, so
    if I was to replace the same control with a label or textbox, it works fine.
    Here is the code,

    case "RequiredFieldValidator":
    RequiredFieldValidator cReq = (RequiredFieldValidator)ctrl;
    cReq.ID = System.Guid.NewGuid().ToString();

    Thanks for your help!
    vibs, Jan 20, 2006
    1. Advertisements

  2. Phillip Williams, Jan 20, 2006
    1. Advertisements

  3. try:
    mcell.Parent = this;

    ASP renders the ID as ClientID (or UniqueID, I can never remember), which
    qualifies them via the IDs of the parental hierarchy. However, the parent
    must be non-null, so I am guessing that mcell has no parent at this point?
    Keith Patrick, Jan 20, 2006
  4. vibs

    vibs Guest


    I am not creating a new control. I am just using an existing
    RequiredValidator Control.

    vibs, Jan 20, 2006
  5. vibs

    vibs Guest

    mcell.parent is a readonly property. I am adding the control to a cell in a
    table. I so see the mcell.parent has a uniqueid on each iteration. And again
    this is happening only for validator controls so something else is going on

    vibs, Jan 20, 2006
  6. Sorry about that...forgot that it gets set during Controls.Add (I didn't
    compile it to check)
    Keith Patrick, Jan 21, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.