Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox problem

Status
Not open for further replies.

vijraj

Programmer
Mar 14, 2007
11
US
Hi all!
I have created a web form in which I have a listbox and a button.I populated the listbox at form load and then I select an listbox item.When I go to the button click event, I don't get the listbox.item as selected though I select it.What is the problem?
appreciate any kind of help.Thanks.

here is the sample code.

ListItem item;
for(int iter = 1;iter < lsCage.Items.Count;iter++)
{
item = lsCage.Items[iter];
if (item.Selected)// this is always false why?
{

String cageNumber = item.Value.ToString();
xmlZoo = new XmlDocument();
XmlNodeList cages;
XmlElement root = xmlZoo.DocumentElement;
cages = root.SelectNodes("Cage");
 
Please see if the listbox control is not getting
re-populated on Postback under Page_Load.

Also, we can use listbox.SelectedValue property as an alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top