473,387 Members | 1,641 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,387 software developers and data experts.

Repeater and File List Help

Ok, so I thoguht I was close but must be missing something. I am
trying to get a list of files from a directory and display them in a
clickable list using the Repeater control. It seems as if I am getting
the files and adding them to the object, but something is getting lost
or I am not sure how to display on the HTML side. I have something to
the effect of:

HTML side:

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "FileInfoPath") %>
</ItemTemplate>
</asp:Repeater>

Code Side:

private void showFiles(object sender, System.EventArgs e)
{
try
{
appPath = appPath + "/TestApp/";

DirectoryInfo dir = new DirectoryInfo("c:/test");

ArrayList aryFiles = new ArrayList();

FileInfo[] allFiles = dir.GetFiles("*.*");

foreach (FileInfo f in allFiles)
{
FileRelatedInfo objData = new FileRelatedInfo();
objData.FileInfoTitle = f.Name;
objData.FileInfoPath = appPath +
Page.Server.UrlPathEncode(f.Name);
aryFiles.Add(objData.FileInfoPath);
}
Repeater1.DataSource = aryFiles;
Repeater1.DataBind();
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}

public class FileRelatedInfo
{
public string FileInfoTitle;
public string FileInfoPath;
}

Error from try/catch block:

System.Web.HttpException: DataBinder.Eval: 'System.String' does not
contain a property with the name FileInfoPath. at
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) at System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts) at System.Web.UI.DataBinder.Eval(Object container,
String expression) at ASP.usrFileList_ascx.__DataBind__control3(Object
sender, EventArgs e)

Nov 17 '05 #1
2 4684
You are adding a string into the aryFiles ArrayList which you are then
setting as the DataSource and in the Eval statement you are trying to get a
property named "FileInfoPath" from the string that you entered. System.String
(the same as "string") does not have a property called "FileInfoPath".

Changing the line "aryFiles.Add(objData.FileInfoPath);" to
"aryFiles.Add(objData);" will sort your problem.

Hope this helps.

--
Brian Delahunty
Ireland

http://briandela.com/blog
"hartbypass" wrote:
Ok, so I thoguht I was close but must be missing something. I am
trying to get a list of files from a directory and display them in a
clickable list using the Repeater control. It seems as if I am getting
the files and adding them to the object, but something is getting lost
or I am not sure how to display on the HTML side. I have something to
the effect of:

HTML side:

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "FileInfoPath") %>
</ItemTemplate>
</asp:Repeater>

Code Side:

private void showFiles(object sender, System.EventArgs e)
{
try
{
appPath = appPath + "/TestApp/";

DirectoryInfo dir = new DirectoryInfo("c:/test");

ArrayList aryFiles = new ArrayList();

FileInfo[] allFiles = dir.GetFiles("*.*");

foreach (FileInfo f in allFiles)
{
FileRelatedInfo objData = new FileRelatedInfo();
objData.FileInfoTitle = f.Name;
objData.FileInfoPath = appPath +
Page.Server.UrlPathEncode(f.Name);
aryFiles.Add(objData.FileInfoPath);
}
Repeater1.DataSource = aryFiles;
Repeater1.DataBind();
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}

public class FileRelatedInfo
{
public string FileInfoTitle;
public string FileInfoPath;
}

Error from try/catch block:

System.Web.HttpException: DataBinder.Eval: 'System.String' does not
contain a property with the name FileInfoPath. at
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) at System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts) at System.Web.UI.DataBinder.Eval(Object container,
String expression) at ASP.usrFileList_ascx.__DataBind__control3(Object
sender, EventArgs e)

Nov 17 '05 #2
Sorry about that, I did not realize I left that line in there. I was
just adding the objData and was getting this:

System.Web.HttpException: DataBinder.Eval:
'SMIntranet.UserControls.usrFileList+FileRelatedIn fo' does not contain
a property with the name FileInfoPath. at
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) at System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts) at System.Web.UI.DataBinder.Eval(Object container,
String expression) at ASP.usrFileList_ascx.__DataBind__control3(Object
sender, EventArgs e)

I added the objData.FileInfo*Path just shooting in the dark.

Nov 17 '05 #3

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

Similar topics

5
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of...
2
by: | last post by:
Hi I'm trying to have a drop down list inside a repeater where the data for the list is extracted from a database along with other items but I can't seem to get it to work for the list. My...
3
by: Fredrik Rodin | last post by:
All, I'm looking for a way of generating a grouping in a repeater (or other control). Instaed of describing everything here, just look at this link and you can see how I did it in classic asp...
4
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so...
2
by: Benign Vanilla | last post by:
I created a web site in ASP that is heavily data driven. On the home page, http://iheartmypond.com/. The list of categories is gathered from the database. I grab the distinct top level categories,...
3
by: Øyvind Isaksen | last post by:
I have a reperater that returns 5 last articles from a given category. In the bottom of the list (in the FooterTemplate) I want to make a link to a page that list all articles in this category....
8
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
2
by: champ.supernova | last post by:
I have a repeater, which contains in its <HEADERTEMPLATEa drop-down list (set to autopostback). If the page is a postback, I want to modify the SQL of the repeater's datasource, DEPENDING ON the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.