Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > multiple listbox selections

Reply
Thread Tools

multiple listbox selections

 
 
bill yeager
Guest
Posts: n/a
 
      08-12-2003
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.Object
> System.Web.UI.Control
> System.Web.UI.WebControls.WebControl
> System.Web.UI.WebControls.ListControl
> System.Web.UI.WebControls.ListBox
>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.2003FEB.1033/cpref/html/frl

r
>fsystemwebuiwebcontrolslistboxclassselectionmodet opic.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.WebControls.CheckBoxList
> System.Web.UI.WebControls.DropDownList
> System.Web.UI.WebControls.ListBox
> System.Web.UI.WebControls.RadioButtonList
>controls... Ask if you need something like that
>
>
>>-----Original Message-----
>>I have a listbox in a datagrid that can contain up to

two
>>selections. How can I return the selected indexes of the
>>two values? I know how to do it for a listbox that has a
>>selectionmode of "single", but not for multiple.
>>
>>Here is my HTML:
>><asp:TemplateColumn HeaderText="Riders">
>>
>> <ItemTemplate>
>>
>> <asp:listbox AutoPostBack="False"
>>BackColor="#ffffff" id="lstRider" runat="server"

Rows="1"
>>DataSource="<%# DsRider1 %>" Enabled="True"
>>SelectionMode="Multiple" DataTextField="UserName"
>>DataValueField="UserName" SelectedIndex='<%#
>>GetRiderUserName() %>' />
>>
>> </asp:listbox>
>>
>> </ItemTemplate>
>>
>> </asp:TemplateColumn>
>>
>>
>>I'm executing a function "GetRiderUserName" 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 GetRiderUserName() 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.Rows.Count
>> If DsCalDteRider1.CalDteRiders.Item
>>(i).Username = DsRider1.Riders.Item(i).Username 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
>>.
>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox losing multiple selections thru proxy, but not locally bthomasIDFG ASP .Net Web Controls 0 10-12-2005 12:01 AM
asp:ListBox multiple selections Chris Kettenbach ASP .Net 5 10-07-2005 08:01 PM
Multi-select listbox losing selections - answered zdrakec ASP .Net 0 07-22-2005 09:33 PM
Multi-select listbox losing selections zdrakec ASP .Net 0 07-22-2005 07:51 PM
Obtaining Data Based Upon Multiple Selections From a ListBox... =?Utf-8?B?QWRpcw==?= ASP .Net 0 10-19-2004 01:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57