Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > I set listbox.datasource to fileinfo() object, but no files appear in the listbox.

Reply
Thread Tools

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

 
 
COHENMARVIN
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3JlZWppdGggUmFtKE1DU0QuTkVUKQ==?=
Guest
Posts: n/a
 
      10-14-2005
well, have you got a line imgBanner.DataBind();
after imgBanner.DataSource = fileInfos; ?

or just omitted it in the question?


"COHENMARVIN" wrote:

> 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm trying to get the keys, but why values appear? Abder-rahman Ali Ruby 4 07-13-2010 09:21 AM
Win32API GetOpenFileName called successful, but no dialog appear,why? yang cao Ruby 0 04-09-2007 04:21 PM
dhtml question: images appear in FireFox but not in IE Jake Barnes Javascript 0 01-04-2007 06:02 AM
Thunderbird 1.0 -- extensions install but do not appear in list Mark Adams Firefox 0 02-14-2005 12:55 AM
why do replies appear on google but not here? Tsotsi Computer Support 1 07-03-2004 09:59 PM



Advertisments