473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

Nov 19 '05 #1
1 1385
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bernie Yaeger | last post by:
I now know how to gather the file type icons and I'm able to use them in a listview. But a listbox does not have a .smallimagelist or .largeimagelist member, so I don't know how to translate that...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
4
by: Seok Bee | last post by:
Dear Experts, I am having 1 listbox control in my web form and trying to retrieve the items and load into it. I want to list out those uploaded files into the database and list out in the...
1
by: WhiteWizard | last post by:
First my apologies, this may be longer than the normal question. I have a windows app (.NET 2.0, VS2005), and I've written a user control that will allow the user to "drag and drop" a directory...
4
by: Dave | last post by:
I'm using the below code to populate a ListBox with file content information. Sorting the information alpha/numerically is now an issue. Would someone please let me know the best aproach to take...
11
by: MrQuan | last post by:
I must say, I'm completly stumped at what should be a very simple sub... It's purpose is to fill a ListBox with filenames from the path specified. I know Files() receives the filenames, however...
4
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not...
0
by: crespo | last post by:
hi,everyone. I have a question about using listbox in a customized user control.I use a listbox directly in a asp.net page and it works very well,but when I use the same code in a user...
4
by: Rotsey | last post by:
Hi, I have a listbox and I am adding objects to it with AddRange. The problem is the listbox just shows the name of object class in every row and not the DisplayMember see below. Any...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.