PDA

View Full Version : ASP.NET databinding problem


david7777
04-10-2003, 12:32 PM
I am trying to have a datagrid which has paging and sorting functions - that the easy part. Now instead of using a database or XML file for the source, i want to use an array or sortedList or something... I am looping a certain amount of times(anything from 0 - 99999 depending on user input) and want to create a list of strings (urls). At the moment i am using an ArrayList. That is all ok. The problem comes in when i want to bind the ArrayList to the datagrid.

I use the following which seems to work:

DataGrid1.dataSource = myArrayList
DataGrid1.dataBind()


Then the problem comes in when i need to use the data:

<a href='<%# DataBinder.Eval(Container.DataItem, "url") %>'>
<img src='<%# DataBinder.Eval(Container.DataItem, "url") %>' border='1' width="60" height="60" />
</a>


I get the error:
System.Web.HttpException: DataBinder.Eval: 'System.Collections.DictionaryEntry' does not contain a property with the name url.
The error makes sense because i have no named columns in my arrayList, but how do i get around it?