HELP! DropDownList Items property in composite control -- collection editor support question!

Discussion in 'ASP .Net Building Controls' started by Nguyen Ly, Nov 4, 2003.

  1. Nguyen Ly

    Nguyen Ly Guest

    Hi,

    I have a composite web custom control consisting of a textbox, a button, and
    a dropdownlist..
    I'm trying to expose the Items property from the dropdownlist and it works
    fine if I use code to populate the drop down.

    When I try to use the Collection editor to add in ListItems by clicking on
    the three "..." button next to the Items property, it sort of adds in the
    ListItems but the HTML view on the aspx page doesn't show child listitem
    controls the way the the DropDownList control does..
    ie it does <custom:MyControl id="MyCustomControl" Items="(Collections)" ...
    so when I build .. theres an error saying the Items property is read only.

    I want the ability to use the visual design-time collection editor with my
    composite control in VS so when I click on the three "..." button next to
    the Items property.. it allows me to add in ListItems just like the
    DropDownList does, and puts in something like this:

    <custom:MyControl id="MyCustomControl">
    <asp:ListItem value="1">One</asp:ListItem>
    <asp:ListItem value="1">Two</asp:ListItem>
    </custom:MyControl>

    Does anyone know how I can go about doing this?

    Thanks for your time :)
    Nguyen Ly, Nov 4, 2003
    #1
    1. Advertising

  2. Nguyen Ly

    Teemu Keiski Guest

    Hi,

    you should apply certain attributes for the property that exposes the
    collection.

    [
    PersistenceMode(PersistenceMode.InnerProperty),

    DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    NotifyParentProperty(true)
    }
    ....property goes here

    Also note that the property should be read-only and utilize lazy
    instantiation.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "Nguyen Ly" <> wrote in message
    news:...
    > Hi,
    >
    > I have a composite web custom control consisting of a textbox, a button,

    and
    > a dropdownlist..
    > I'm trying to expose the Items property from the dropdownlist and it works
    > fine if I use code to populate the drop down.
    >
    > When I try to use the Collection editor to add in ListItems by clicking on
    > the three "..." button next to the Items property, it sort of adds in the
    > ListItems but the HTML view on the aspx page doesn't show child listitem
    > controls the way the the DropDownList control does..
    > ie it does <custom:MyControl id="MyCustomControl" Items="(Collections)"

    ....
    > so when I build .. theres an error saying the Items property is read only.
    >
    > I want the ability to use the visual design-time collection editor with my
    > composite control in VS so when I click on the three "..." button next to
    > the Items property.. it allows me to add in ListItems just like the
    > DropDownList does, and puts in something like this:
    >
    > <custom:MyControl id="MyCustomControl">
    > <asp:ListItem value="1">One</asp:ListItem>
    > <asp:ListItem value="1">Two</asp:ListItem>
    > </custom:MyControl>
    >
    > Does anyone know how I can go about doing this?
    >
    > Thanks for your time :)
    >
    >
    Teemu Keiski, Nov 6, 2003
    #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. sleigh
    Replies:
    1
    Views:
    2,687
    sleigh
    Feb 12, 2004
  2. Alexander Popov

    Collection Editor in Composite Controls

    Alexander Popov, May 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,531
    Natty Gur
    May 26, 2004
  3. Øyvind Isaksen
    Replies:
    1
    Views:
    966
    Øyvind Isaksen
    May 18, 2007
  4. Chad
    Replies:
    0
    Views:
    221
  5. Replies:
    1
    Views:
    287
    Tim Dot NoSpam
    May 19, 2006
Loading...

Share This Page