|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DropDownList with default valuesHi 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. 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. > 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. > > > > > 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. >>>
Protected Shadows With Events.
dynamic textbox empty string Page.RegisterClientScriptBlock() is not working ..... :-( How do I access HTML controls from the code behind? Gridview OnPageIndexChanging not firing in beta 2 e.Item.Cells.Count in UpdateCommand event of Datagrid Binding Data to IE Treeview control Can a User Control display a pdf or static html file? ASP.NET Book Recommendation How to filter two combos on grid clientside |
|||||||||||||||||||||||