473,326 Members | 2,076 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,326 software developers and data experts.

Bind ArrayList to DataList

Hi,

I'm trying to bind an ArrayList to a DataList.

I get the error
DataBinder.Eval: 'System.String' does not contain a property with the name
Name.

I don't know what property of ArrayList I should be using instead of "Name"
in default.aspx.

Can someone point me in the right direction?

default.aspx.vb -
Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
Dim FileList As FileInfo() = di.GetFiles()
Dim File As FileInfo
Dim ary As New ArrayList
For Each File In FileList
ary.Add(File.Name)
Next

ThumbList.DataSource = ary
ThumbList.DataBind()

default.aspx -
<asp:datalist id="ThumbList"
repeatdirection="Horizontal"
repeatcolumns="5"
gridlines="Both"
repeatlayout="Table"
itemstyle-cssclass="thumb"
runat="server">
<itemtemplate>
<img src='images/position/thumb/<%#DataBinder.Eval(Container,
"DataItem.Name")%>">' border='0'></a>
</itemtemplate>
</asp:datalist>

Thanks,
Bob Lehmann
Nov 19 '05 #1
3 3318
Bob,

without testing I'd assume that sth. like the following should work:

Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
ThumbList.DataSource= di.GetFiles()
ThumbList.DataBind()

Does this help?

Best regards

Daniel Walzenbach
"Bob Lehmann" <no****@dontbotherme.zzz> schrieb im Newsbeitrag
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to bind an ArrayList to a DataList.

I get the error
DataBinder.Eval: 'System.String' does not contain a property with the name
Name.

I don't know what property of ArrayList I should be using instead of
"Name"
in default.aspx.

Can someone point me in the right direction?

default.aspx.vb -
Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
Dim FileList As FileInfo() = di.GetFiles()
Dim File As FileInfo
Dim ary As New ArrayList
For Each File In FileList
ary.Add(File.Name)
Next

ThumbList.DataSource = ary
ThumbList.DataBind()

default.aspx -
<asp:datalist id="ThumbList"
repeatdirection="Horizontal"
repeatcolumns="5"
gridlines="Both"
repeatlayout="Table"
itemstyle-cssclass="thumb"
runat="server">
<itemtemplate>
<img src='images/position/thumb/<%#DataBinder.Eval(Container,
"DataItem.Name")%>">' border='0'></a>
</itemtemplate>
</asp:datalist>

Thanks,
Bob Lehmann

Nov 19 '05 #2
Thanks.

I've tried that. However, the problem is that I need just the image name
from the ArrayList.

I've done this before, where each Name was a property of a class. In this
case, I don't need this kind of granularity, and just want to grab the value
from the ArrayList.

Bob Lehmann
"Daniel Walzenbach" <da***************@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Bob,

without testing I'd assume that sth. like the following should work:

Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
ThumbList.DataSource= di.GetFiles()
ThumbList.DataBind()

Does this help?

Best regards

Daniel Walzenbach
"Bob Lehmann" <no****@dontbotherme.zzz> schrieb im Newsbeitrag
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to bind an ArrayList to a DataList.

I get the error
DataBinder.Eval: 'System.String' does not contain a property with the name Name.

I don't know what property of ArrayList I should be using instead of
"Name"
in default.aspx.

Can someone point me in the right direction?

default.aspx.vb -
Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
Dim FileList As FileInfo() = di.GetFiles()
Dim File As FileInfo
Dim ary As New ArrayList
For Each File In FileList
ary.Add(File.Name)
Next

ThumbList.DataSource = ary
ThumbList.DataBind()

default.aspx -
<asp:datalist id="ThumbList"
repeatdirection="Horizontal"
repeatcolumns="5"
gridlines="Both"
repeatlayout="Table"
itemstyle-cssclass="thumb"
runat="server">
<itemtemplate>
<img src='images/position/thumb/<%#DataBinder.Eval(Container,
"DataItem.Name")%>">' border='0'></a>
</itemtemplate>
</asp:datalist>

Thanks,
Bob Lehmann


Nov 19 '05 #3
Bob,

You are adding the string to the array. Name is not a member of the string
class (i know i just repeated the error). Change ary.Add(File.Name) to
ary.Add(File) and your bind should work fine.

For a more efficient approach, i believe that you can leave the
ary.Add(File.Name) but change the binding command to <img
src='images/position/thumb/<%#DataBinder.Eval(Container.DataItem)%>'>

Hope that helps,
Darren Kopp
http://blog.secudocs.com/

"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:OZ**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to bind an ArrayList to a DataList.

I get the error
DataBinder.Eval: 'System.String' does not contain a property with the name
Name.

I don't know what property of ArrayList I should be using instead of
"Name"
in default.aspx.

Can someone point me in the right direction?

default.aspx.vb -
Dim di As New DirectoryInfo(Current.Server.MapPath("images/position"))
Dim FileList As FileInfo() = di.GetFiles()
Dim File As FileInfo
Dim ary As New ArrayList
For Each File In FileList
ary.Add(File.Name)
Next

ThumbList.DataSource = ary
ThumbList.DataBind()

default.aspx -
<asp:datalist id="ThumbList"
repeatdirection="Horizontal"
repeatcolumns="5"
gridlines="Both"
repeatlayout="Table"
itemstyle-cssclass="thumb"
runat="server">
<itemtemplate>
<img src='images/position/thumb/<%#DataBinder.Eval(Container,
"DataItem.Name")%>">' border='0'></a>
</itemtemplate>
</asp:datalist>

Thanks,
Bob Lehmann

Jan 4 '06 #4

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

Similar topics

0
by: VbScripter | last post by:
In the code below, I have an editItemTemplate that will have to have a long list of ip's bound to it. The problem is that the lisbox is not seen by asp.net until after the datalist containing it...
0
by: Steven | last post by:
I'm using C# as code-behind language. I have 2 arraylists (name, value) of equal length. I want to display the values in the array lists on my webpage using datalist. I want to display them in...
1
by: Steven | last post by:
I have an arraylist and I want to display all the values in the arraylist in a new window (asp.net page) using a datalist. The new window should be like a small popup window. How can I do this? ...
2
by: Morten Hauge | last post by:
Hi! I have a problem, I'm not sure if this is the proper way to do it, but I have the following scenario: I want to list all categories, and all products in that category whenever I select a...
3
by: serge calderara | last post by:
Dear all, Does anyone know how to bind a System.Collection.ArraysList object to a Dataset ? Thanks for your reply Regards Serge
3
by: sck10 | last post by:
Hello, I am trying to bind an arraylist to a FormView DropDownList control in the PreRender state. The error that I get is the following: Databinding methods such as Eval(), XPath(), and...
2
by: ASP Developer | last post by:
Is it possible to bind a datalist that is inside of a bound datalist? Any help would be greatly appreciated.
0
by: pbd22 | last post by:
Hi. I am returning to an old bit of code in our program and need to figure out how to sort my columns on bind. I am sorting on Date (mostly) and some other values. Problem is, the code is an...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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

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.