473,770 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need selectedvalue of multi list box

I need to get the SelectedValue of each item selected in a
multi-selection listbox. I have the following code, but it
just returns me the SelectedValue of ONLY the first item
selected in the list:
Dim liGroup As ListItem

For Each liGroup In lstGroups.Items

If liGroup.Selecte d = True Then

blnSelected = True

Dim drGroupBridge As
dsACL.GroupBrid geRow = DsACL1.GroupBri dge.NewGroupBri dgeRow

drGroupBridge.U serID =
lstGroupUsers.S electedValue

drGroupBridge.G roupID =
lstGroups.Selec tedValue

DsACL1.GroupBri dge.Rows.Add
(drGroupBridge)

End If

Next


It does cycle thru the code twice (because I have two
items selected), so it's performing the loop fine.
However, the following line above "drGroupBridge. GroupID =
lstGroups.Selec tedValue", is the code I need to check for
the multiple SelectedValues from the lstGroups listbox.
It's only returning the first item selected in the list.

How can I accomplish this? What code am I missing???
Nov 18 '05 #1
2 2157
If i understand you correctly, you have a listbox with multiselect set to
true. You have selected two items out of the list and you are looping thru
the items looking for the selected item value which is set to true. The loop
construct only returns the very first selected item whether or not multiple
items are selected. Is this accurate? This is an ASP.NET listbox?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"bill yeager" <an*******@disc ussions.microso ft.com> wrote in message
news:6b******** *************** *****@phx.gbl.. .
I need to get the SelectedValue of each item selected in a
multi-selection listbox. I have the following code, but it
just returns me the SelectedValue of ONLY the first item
selected in the list:
Dim liGroup As ListItem

For Each liGroup In lstGroups.Items

If liGroup.Selecte d = True Then

blnSelected = True

Dim drGroupBridge As
dsACL.GroupBrid geRow = DsACL1.GroupBri dge.NewGroupBri dgeRow

drGroupBridge.U serID =
lstGroupUsers.S electedValue

drGroupBridge.G roupID =
lstGroups.Selec tedValue

DsACL1.GroupBri dge.Rows.Add
(drGroupBridge)

End If

Next


It does cycle thru the code twice (because I have two
items selected), so it's performing the loop fine.
However, the following line above "drGroupBridge. GroupID =
lstGroups.Selec tedValue", is the code I need to check for
the multiple SelectedValues from the lstGroups listbox.
It's only returning the first item selected in the list.

How can I accomplish this? What code am I missing???

Nov 18 '05 #2
"bill yeager" <an*******@disc ussions.microso ft.com> wrote in
news:6b******** *************** *****@phx.gbl:

I'm not sure if I understand exactly what you're saying, but it seems to me
that instead of this:

drGroupBridge.G roupID = lstGroups.Selec tedValue

your code should read:

drGroupBridge.G roupID = liGroup.Value
Brett
I need to get the SelectedValue of each item selected in a
multi-selection listbox. I have the following code, but it
just returns me the SelectedValue of ONLY the first item
selected in the list:
Dim liGroup As ListItem

For Each liGroup In lstGroups.Items

If liGroup.Selecte d = True Then

blnSelected = True

Dim drGroupBridge As
dsACL.GroupBrid geRow = DsACL1.GroupBri dge.NewGroupBri dgeRow

drGroupBridge.U serID =
lstGroupUsers.S electedValue

drGroupBridge.G roupID =
lstGroups.Selec tedValue

DsACL1.GroupBri dge.Rows.Add
(drGroupBridge)

End If

Next


It does cycle thru the code twice (because I have two
items selected), so it's performing the loop fine.
However, the following line above "drGroupBridge. GroupID =
lstGroups.Selec tedValue", is the code I need to check for
the multiple SelectedValues from the lstGroups listbox.
It's only returning the first item selected in the list.

How can I accomplish this? What code am I missing???


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4606
by: Jeff Thur | last post by:
I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing values that the user inputs into Text boxes to my Stored Procedure. However I have a drop down list with a listing of the individual States, which the user selects. I am trying to use the SelectedValue of the drop down list but I am getting a...
4
6270
by: Mantova | last post by:
Maybe it's simple, but I can't get it to work. I'm originally a webdeveloper, and just started to work on a C# windows application. I want a list, something similar to a <select><option> object, where the displayed value is different from the real value. I populate the list like this, where I assume that SelectedValue is something like the <option value="ID"> while (sql.Read()) {
1
3624
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass". Each combobox has its datasource, displaymember and SelectedValue member bound to separate tables thru individual datatsets thru individual data adapters. The two tables are "Class" and "SubClass". I use parameterized query to populate the...
7
1928
by: ÀÏÆÅ»³ÔÐ5¸öÔ | last post by:
I want use dropdownlist contral in gridview but have trouble now mycode here: i'm very sorry for my poor english <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
8103
by: Dooman | last post by:
Hello, I am getting this error when binding a drop down list box to a dataset: The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive I have looked at other posts and they al refer to this error when accessing data in the list box.
2
9959
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
2
5546
by: =?Utf-8?B?U3RlcGhlbiBSaXRjaGll?= | last post by:
Hi NET1.1 / Winforms I have a listbox that I am binding to a table via the DataSource property. However I want to be able to programmatically select values in this listbox so I am using the code below... With lstJobTypes .DataSource = BusinessRules.Common.JobTypes.All(True)
0
1557
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
11
3325
Frinavale
by: Frinavale | last post by:
This question is going to sound a little crazy but.........How do you set the selected item in a ComboBox? I am populating a ComboBox with a bunch of instances of a custom private class: For Each s as Something In MyListOfSomethings MyComboBox.Items.Add(New XYZListItem(s.ID,s.description)) Next MyComboBox.ValueMember = "ID" MyComboBox.DisplayMember = "Description"
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.