473,883 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple listbox selections

Duray, it helps in regards to knowing how to get the items
that were selected in the lisbox, but I'm going in
reverse --- after I get the items from the db that were
selected, I'd like to be able to highlight them in the
listbox within the datagrid control........ .

Thanks,

Bill...
-----Original Message-----
Hi Bill,

If you are talking about:
System.Objec t
System.Web.UI.C ontrol
System.Web.UI.W ebControls.WebC ontrol
System.Web.UI.W ebControls.List Control
System.Web.UI.W ebControls.List Box
ther is mo way to get the selected items without iterating.
Lets say you have ListBox1

foreach (ListItem li in myListBox.Items )
{
if(li.Selected)
{
// put the code for selected Item
}
}
In VS.NET2003 help:
ms-
help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpref/html/frl rfsystemwebuiwe bcontrolslistbo xclassselection modetopic.htm

Hope It Helps

Duray AKAR

PS:
I have a piece of static code somewhere that gives the
selected items for any given
System.Web.UI.W ebControls.Chec kBoxList
System.Web.UI.W ebControls.Drop DownList
System.Web.UI.W ebControls.List Box
System.Web.UI.W ebControls.Radi oButtonList
controls... Ask if you need something like that

-----Original Message-----
I have a listbox in a datagrid that can contain up to twoselections. How can I return the selected indexes of the
two values? I know how to do it for a listbox that has a
selectionmo de of "single", but not for multiple.

Here is my HTML:
<asp:Template Column HeaderText="Rid ers">

<ItemTemplate >

<asp:listbox AutoPostBack="F alse"
BackColor="#f fffff" id="lstRider" runat="server" Rows="1"DataSource="< %# DsRider1 %>" Enabled="True"
SelectionMode ="Multiple" DataTextField=" UserName"
DataValueFiel d="UserName" SelectedIndex=' <%#
GetRiderUserN ame() %>' />

</asp:listbox>

</ItemTemplate>

</asp:TemplateCol umn>
I'm executing a function "GetRiderUserNa me" in my code-
behind to return the selected indices, but don't quite
know how to do it. This is as far as I've got:

Public Function GetRiderUserNam e() As Integer

'Returns the index of the username
Dim i As Integer
Dim blnFound As Boolean = False
Dim bytFoundCnt As Byte = 0

For i = 0 To

DsCalDteRider1 .CalDteRiders.R ows.Count
If DsCalDteRider1. CalDteRiders.It em
(i).Usernam e = DsRider1.Riders .Item(i).Userna me Then
blnFound = True
If bytFoundCnt = 2 Then 'Max selections
allowed
Exit For
End If
Else
blnFound = False
End If
Next

If blnFound Then
Return DsRider1.Riders .Item(i).RowNbr
Else
Return -1
End If

End Function

How can I turn "Return DsRider1.Riders .Item(i).RowNbr "
into the selected indexes of a possible two selections?

Thanks,

Bill
.

.

Nov 17 '05 #1
0 2055

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

Similar topics

1
3565
by: theoryboy | last post by:
I'm trying to implement multiple selection functionality in a Tix Hlist using a control-click. I've bound control-click to a function that uses selection_set to add to the selection, but it doesn't seem to work. Only the last clicked item appears selected (highlighted) in the display and the return from info_selection only ever contains the last 2 items, rather than all the items I have control-clicked. It's odd, because if I set up the...
8
7704
by: deko | last post by:
How do I get the items selected from a datasheet? Does a datasheet support multiple selections? I know a ListBox has a "Selected" property that can be used when the MultiSelect property is set - but is there a way to get the same functionality with a datasheet? If not, I'm throwing all my datasheets in the junk..... why bother with datasheets? get all the same functionality with a listbox?
2
6618
by: Jen F. | last post by:
I have inherited a medical database in which there are multiple values stored in a single field (ie. "Current Conditions" field might contain 1-20 different conditions, separated by comma (ie. "Heart Disease,Hyper Tyroid,Cancer" etc. I would like to search via combo box for any one or more than one value in this field, ie-what patients have Heart Disease or Cancer by selecting these disorders off the combo box list. Any help would be...
0
3522
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list boxes do not necessarily need to have a selection made to be used in the dynamic query. In essence the form can have selections made in all or none of its list boxes to form the dynamic query I am looking to get some feedback in reference to...
2
2109
by: Craig B. | last post by:
I am relativly new to access 2000 and am having some trouble with a report. I am not sure what I want to do is something I can do in access. I want to be able to choose from a combo box multiple selections in a form and from those selections present them in a report. For example select a selection A,B, and C out of 9 possible choices. Then show them seperated by a comma in a field in the report. I also want the option of only selecting...
2
1608
by: Steffen Loringer | last post by:
Hi all, may be an easy question: How can I allow multiple selections in a dropdownlist? Thanks Steffen
1
2772
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have to be able to select multiple items, and fill a datagrid with the results. I can fill 2 listboxes and a datagrid, but not with multiple selections. So far, I have no code behind, I have completed it with just using the characteristics of the...
0
1405
by: Gunnar Hurtig | last post by:
Hi All I am relatively new to Tkinter and am putting a wraparound to the ATNF ASAP program. In one part I present several long lists in list boxes for selection. My code will remember the multiple selections made but I woul also like to highlight and maintain the highlighted items as I make additional selections. I can maintain the highlighted selections from listbox to listbox, but can't seem to figure out how to maintain the selected...
12
4056
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just not several, to report using this code i found - Private Sub cmdPreview_Click()
0
9943
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...
0
9793
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10750
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
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
5804
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...
1
4619
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
3
3237
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.