codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Need help with ListBox control  bLinded at 00:32 on Friday, October 22, 2004
 

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.










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Help: Trouble with z-Index and SELECT lists
•  What is wrong with this ASP codes? It don`t seem to work???
•  Need help with ListBox control
•  Re: Good Javascript/DHTML Reference
•  Re: scrolling table
•  Re: simulation of road traffic
•  ASP.NET calendar help
•  Re: Hosting Plan or Scam?
•  Re: Source Control


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004