Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DropDownList in composite control not saving ListItems

Reply
Thread Tools

DropDownList in composite control not saving ListItems

 
 
Steve Trandahl
Guest
Posts: n/a
 
      05-26-2005
I have a composite control consisting of a DropdownList control and a button.
I've included an Items property that returns a reference to the
DropDownList's Items property, but when I add ListItems to it in Design mode,
they aren't added as <asp:ListItem> in the HTML tab. Instead
"Items=(Collection)" appears in the Control's tag and the designer eventually
"forgets" the ListItems that were entered.

How do I get the designer to add an asp:ListItem for each Item the way it
does with the standard DropDownList that's part of my control?

Thanks,
Steve
 
Reply With Quote
 
 
 
 
Steve Trandahl
Guest
Posts: n/a
 
      05-27-2005
I now have this half working. I can persist the ListItems the way I want, but
if I'm interpreting this correctly, the parser isn't able to read it back in.
It thinks I need a property "asp:ListItem".

See http://blogs.aspadvice.com/jlovell/a...02/29/663.aspx

"Steve Trandahl" wrote:

> I have a composite control consisting of a DropdownList control and a button.
> I've included an Items property that returns a reference to the
> DropDownList's Items property, but when I add ListItems to it in Design mode,
> they aren't added as <asp:ListItem> in the HTML tab. Instead
> "Items=(Collection)" appears in the Control's tag and the designer eventually
> "forgets" the ListItems that were entered.
>
> How do I get the designer to add an asp:ListItem for each Item the way it
> does with the standard DropDownList that's part of my control?
>
> Thanks,
> Steve

 
Reply With Quote
 
 
 
 
Steve Trandahl
Guest
Posts: n/a
 
      05-27-2005
I solved my problem by doing three more things:
1) using ParseChildrenAttribute(true, "Items") instead of
ParseChildrenAttribute(true) so it knew the information linked to the "Items"
property instead of an "asp:ListItem" property.
2) Made the Items property read only. When I didn't do that, I got a strange
error - '' could not be set on property "Items".
3) Executed this.EnsureChildControls() before attempting to read the Items
property of the DropDownList that was part of the composite control. This
caused the error "Items could not be initialized" which I assumed was a
parsing error, but wasn't. That became clear when I actually ran the project
and the debugger flagged that line with the error.

I hope this helps others who have these same problems. It's hard to find
information on this.

Steve

"Steve Trandahl" wrote:

> I now have this half working. I can persist the ListItems the way I want, but
> if I'm interpreting this correctly, the parser isn't able to read it back in.
> It thinks I need a property "asp:ListItem".
>
> See http://blogs.aspadvice.com/jlovell/a...02/29/663.aspx
>
> "Steve Trandahl" wrote:
>
> > I have a composite control consisting of a DropdownList control and a button.
> > I've included an Items property that returns a reference to the
> > DropDownList's Items property, but when I add ListItems to it in Design mode,
> > they aren't added as <asp:ListItem> in the HTML tab. Instead
> > "Items=(Collection)" appears in the Control's tag and the designer eventually
> > "forgets" the ListItems that were entered.
> >
> > How do I get the designer to add an asp:ListItem for each Item the way it
> > does with the standard DropDownList that's part of my control?
> >
> > Thanks,
> > Steve

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList ListItems in a VB.NET Web Control Library Jeff ASP .Net 1 03-18-2005 11:28 PM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Exposing ListItems in Composite Control Lisa ASP .Net Web Controls 5 09-23-2004 09:15 AM
Exposing ListItems in Composite Control Lisa ASP .Net Building Controls 0 09-08-2004 03:08 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM



Advertisments