I set listbox.datasource to fileinfo() object, but no files appear in the listbox.

  • Thread starter Thread starter COHENMARVIN
  • Start date Start date
C

COHENMARVIN

I am trying to display the contents of a directory in a listbox. I
manage to get an array of fileInfo objects, and when I print them out
they indeed contain several file names. But when I do
'imgBanner.DataSource = fileInfos', I'm left with an empty listbox.
Here is the code:
=========================
Dim fileInfos() as FileInfo
Dim fi as FileInfo

myDir = New DirectoryInfo(MapPath("/vwSpecials"))
fileInfos = myDir.GetFiles()

For Each fi In fileInfos
strFiles = strFiles & "," & fi.Name
Next
LabDiagnostic.Text = strFiles
imgBanner.DataSource = fileInfos
===============================
The actual control is:
<ASP:Listbox id="imgBanner" runat="server" Rows="1" />

Any help is appreciated.
-- Marvin
 
well, have you got a line imgBanner.DataBind();
after imgBanner.DataSource = fileInfos; ?

or just omitted it in the question?
 
Back
Top