List box problem

  • Thread starter Thread starter Bonzol
  • Start date Start date
B

Bonzol

Vb.Net 2003 Web

Hey there, I am trying to do the simple task of displaying a value or
an index of a selected item in a listbox via

Label5.Text = CStr(lstfileBox.SelectedIndex)

and or

Label5.Text = lstfileBox.SelectedValue

To fill the listbox I use this


Dim windir As String
Dim file As String

windir = Server.MapPath("Files")
lstfileBox.Items.Clear()
Dim files() As String = Directory.GetFiles(windir)

For Each file In files
lstfileBox.Items.Add(System.IO.Path.GetFileName(file))
Next



The box fills fine, and has all the files listed. However, when I try
to display the selected index I always get "-1" and whenever I try and
display the value, I always get "",, nothing at all.

Anyone have any suggestions?
Thanx in advance
 
.....Continued


However, If I do

Label5.Text = lstfileBox.Items(0).Value()

that works. But Thats no use to me
 
Back
Top