Getting error in Custom control

Discussion in 'Software' started by ShakilaRahmanLaboni, Jun 27, 2006.

  1. ShakilaRahmanLaboni

    ShakilaRahmanLaboni

    Joined:
    Jun 27, 2006
    Messages:
    1
    Likes Received:
    0
    Hi,

    I m getting an Error that is my custom DropDownList server control does not allow child controls.

    I've created a custom DropDownList in ASP.Net 2.0

    While using this control in my project I m getting this error.Please help me.

    Shakila
     
    ShakilaRahmanLaboni, Jun 27, 2006
    #1
    1. Advertisements

  2. ShakilaRahmanLaboni

    unholy

    Joined:
    Jun 21, 2005
    Messages:
    3,899
    Likes Received:
    0
    Location:
    Australia
    Hey,

    it would probably be best answered on a ASP.Net forum.
     
    unholy, Jun 27, 2006
    #2
    1. Advertisements

  3. ShakilaRahmanLaboni

    cavalier

    Joined:
    Aug 1, 2007
    Messages:
    1
    Likes Received:
    0
    Dropdown list child controls

    If you inherit from a drop down list you will by default have an empty child controls collection. For some reason dropdown lists do not allow child controls.
    To overcome this you need to override the CreateControlCollection method.

    protected override ControlCollection CreateControlCollection()
    {
    return new ControlCollection(this);
    }
     
    cavalier, Aug 1, 2007
    #3
    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.