By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,562 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,562 IT Pros & Developers. It's quick & easy.

Only the first ListItem is selected in a ListBox

P: n/a
I have a WebForm with a ListBox in it. This SelectionMode is set to Multiple.

When a button is clicked, I check what items are selected using:

foreach (ListItem itm in lb.Items)
{
Trace.Write(itm.Text + ": " + itm.Selected);
}

The trace shows that only the first one selected no matter which items I actually selected in the ListBox.

Anyone has any idea why?
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

You need to attach a handler to SelectedIndexChanged event of your ListBox
and check the selected item there.

-Oleg.
"Raymond" <Ra*****@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
I have a WebForm with a ListBox in it. This SelectionMode is set to Multiple.
When a button is clicked, I check what items are selected using:

foreach (ListItem itm in lb.Items)
{
Trace.Write(itm.Text + ": " + itm.Selected);
}

The trace shows that only the first one selected no matter which items I actually selected in the ListBox.
Anyone has any idea why?

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.