|
I have a mulitple selection listbox which I bind to a query. I want to save all the selected items in a session variable but am finding that when I look for selected items all are returning false. Here's my code:
MyConnection.Open()
dtrReader = MyCommand.ExecuteReader()
Competitors.DataSource = dtrReader
Competitors.DataTextField = "CourseName"
Competitors.DataBind()
dtrReader.Close()
MyConnection.Close()
End Sub
Sub Button8Click (s as Object, e as EventArgs)
Dim c As String
Dim item As ListItem
For each item in Competitors.Items
If item.Selected Then
c = c & item.Text
c = c & ", "
End If
Next
Session("Competitors") = c
Funny thing is the for loop will set c with the selected items if I create the ListItems myself using <asp:ListItem ...../> but it does not work when I use DataBind(). Any help is much appreciated.
|
|
|
|
|
|
|
|