PDA

View Full Version : Display a Dropdownlist w/multiple items Selected


tcadieux
06-06-2008, 06:03 PM
I want to show to an administrator, multiple options that someone will have choosen from a dropdown. I'm having trouble displaying the DropDownlist to the user with multiple items picked, only the last Item appears Selected?




Do While objDataReader.Read = True

Dim ex As ListItemCollection = lbDist_list.Items
Dim ax As ListItem
For Each ax In ex
'Check against the current DataRecord
If ax.Value = Trim(objDataReader("distList_Id")) Then

lbDist_list.SelectedValue = ax.Value

End If
Next

Loop

javabits
06-06-2008, 09:30 PM
Try using a listbox instead.

semper fi...

tcadieux
06-06-2008, 10:52 PM
I did that thx.

I must have a flaw somewhere though, if i do a straightup query in in DB, i get 3 returns - 1,2,3 . When I step through the code, I starts at 2, then hits 3, but 3 is alaways the only item highlighted?


If objDataReader.Read = True Then
Do While objDataReader.Read = True
iDistListID = objDataReader("distlist_id")
Dim ex As ListItemCollection = lbDist_list.Items
Dim ax As ListItem
For Each ax In ex
If ax.Value = iDistListID Then
lbDist_list.SelectedValue = ax.Value
Exit For
End If
Next
Loop

End If

javabits
06-10-2008, 08:25 PM
Think you need to use the selected property of a listitem.

lbDist_list.SelectedValue = ax.Value

should change to

ax.Selected = True

Using the SelectedValue of the listItemCollection implies that you only have a single item selected.

Hope this helps (and works),

semper fi...