473,320 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Only the first ListItem is selected in a ListBox

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
1 1598

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Amil | last post by:
Hi all, I am using VS 2005 Beta 2. Which assembly (namespace?) should I use for the ListItem class? I don't have the Help files installed on my notebook for space reasons; I use MSDN2 online...
1
by: Do | last post by:
Hi, In my listbox, I'd like to change the color of some listitems depending on user security. I tried wrapping the <font color=red></font> around my listitme's .text property, but the tags...
1
by: Raymond | last post by:
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) {...
3
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
0
by: John Smith | last post by:
This is what I am trying to do: <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn Visible="False" DataField="id" ReadOnly="True"...
0
by: John Smith | last post by:
This is what I am trying to do: <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn Visible="False" DataField="id" ReadOnly="True"...
4
by: Kevin Blount | last post by:
As mentioned before, I'm creating a multi-lingual page where the text of the page comes from a database. This page includes a registration form which asks for address information, including the...
2
by: ngchaitra | last post by:
Hi, I have to display tables based on the selected listitem. Suppose if the selected item of the listbox is "Pulse pressure" then table "Tbpulse" has to be visible else table "Tboth" has to be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.