Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a listbox and i want to set items in page load..
XML
<asp:ListBox ID="ListBox_Tag" runat="server" CssClass="ListBox_Tag_Position">
</asp:ListBox>

C#
protected void Page_Load(object sender, EventArgs e)
   {
              what to do?!!!
   }


please Help me
thanks
Posted
Updated 24-Aug-12 3:26am
v2

Is this data driven ? If it's not, why is it being set in code ? You add items to ListBox_Tag.Items in order to add them to the control. I am not sure if ListBox has a datasource/databind paradigm as well, that works best if you have a data based collection to add. Either way, read the documentation, use the intellisense to explore and try some things, it's really reasonably self documenting.
 
Share this answer
 
 
Share this answer
 
v2
Comments
VIPR@T 24-Aug-12 7:54am    
have you get the code??
C#
ListBox_Tag.Items.Add("Item1");
ListBox_Tag.Items.Add("Item2");
ListBox_Tag.Items.Add("Item3");


And in ASP.NEt you have viewstate and postsbacks to worry about so to pupulate it even when buttons are pressed remember the
C#
if(!IsPostback){

}


to encode your adds
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900