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

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
 
G

Guest

well, have you got a line imgBanner.DataBind();
after imgBanner.DataSource = fileInfos; ?

or just omitted it in the question?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top