Driving me nuts! WebForms ListBox losing selection whenever buttonis pushed...

W

WTH

I'm obviously missing something fundamental here.

I have an ASP.Net web page written in C#.

On this page is a list box that is populated with strings when the page is loaded.

There is a button on this page.

If I make a selection in the listbox, and then push the button, my button handler code cannot find any selected items in the list
box and the list box shows visually that it has no selected items.

Obviously this is some sort of 'when you write apps in web pages you must do this' kind of thing.

Anyone have a solution for this?

*** HERE IS THE CODE TO LOOK FOR THE SELECTED ITEMS WHEN BUTTON IS PUSHED ***
//Never evaluates as true
for( int i = 0; i < m_oListSensors.Items.Count; i++ )
{
string l_strSensorIP = "";

if( m_oListSensors.Items.Selected == true )
{
l_strSensorIP = m_oListSensors.Items.ToString();
}
}
*******

WTH
 
W

WTH

LOL, again, I figure it out only after posting for help.

Apparently, web pages reload before the button is processed (go figure) and my page_load method (of course) fills the list box which
removes the selections.

WTH
 

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

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top