Home All Groups Group Topic Archive Search About

DropDownList with default values

Author
21 Apr 2005 2:28 PM
Oleg Ogurok
Hi all,

I'm trying to extend DropDownList ASP.NET control to list US states. What's
the best place to override and fill the Items collection?
I understand Items is of type ListItemCollection, which implements
IStateManager; therefore I only need to populate the collection once. What's
the C#/VB statement to check if this is the first time?

Thanks,

-Oleg.

Author
21 Apr 2005 4:22 PM
Brock Allen
you should put this in Page_Load and only fill it if (!IsPostBack)

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Hi all,
>
> I'm trying to extend DropDownList ASP.NET control to list US states.
> What's
> the best place to override and fill the Items collection?
> I understand Items is of type ListItemCollection, which implements
> IStateManager; therefore I only need to populate the collection once.
> What's
> the C#/VB statement to check if this is the first time?
> Thanks,
>
> -Oleg.
>
Author
21 Apr 2005 5:54 PM
Oleg Ogurok
Perhaps you didn't read my message carefully enough.
I am extending DropDownList class to make it reusable rather than populating
the Items collection in every CodeBehind.

-Oleg.

Show quoteHide quote
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:522379632497009265604640@msnews.microsoft.com...
> you should put this in Page_Load and only fill it if (!IsPostBack)
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Hi all,
> >
> > I'm trying to extend DropDownList ASP.NET control to list US states.
> > What's
> > the best place to override and fill the Items collection?
> > I understand Items is of type ListItemCollection, which implements
> > IStateManager; therefore I only need to populate the collection once.
> > What's
> > the C#/VB statement to check if this is the first time?
> > Thanks,
> >
> > -Oleg.
> >
>
>
>
Author
21 Apr 2005 6:26 PM
Brock Allen
Sure, so populate the data in the Load event. It's the same as the Page_Load
event. In fact the page's load gets the load event by inheriting from the
control base class. So any custom control can handle any of those events.
In terms of how you handle those events, you can either wire up an event
handler yourself or you can override the OnLoad method.

I hope this did answer your question :)

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Perhaps you didn't read my message carefully enough.
> I am extending DropDownList class to make it reusable rather than
> populating
> the Items collection in every CodeBehind.
> -Oleg.
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:522379632497009265604640@msnews.microsoft.com...
>
>> you should put this in Page_Load and only fill it if (!IsPostBack)
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>> Hi all,
>>>
>>> I'm trying to extend DropDownList ASP.NET control to list US states.
>>> What's
>>> the best place to override and fill the Items collection?
>>> I understand Items is of type ListItemCollection, which implements
>>> IStateManager; therefore I only need to populate the collection
>>> once.
>>> What's
>>> the C#/VB statement to check if this is the first time?
>>> Thanks,
>>> -Oleg.
>>>