DropDownList with default values

O

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.
 
O

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.
 
B

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 :)
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top