I'm glad you asked, I didn't know why either. =)
I made some changes and now it works, here's the code. First, the
DataList definition in the .aspx, I removed the ObjectDataSource and
changed from an Image object to just the <img> tag:
<asp:DataList ID="dlThumbNails" runat="server"
RepeatColumns="3" RepeatDirection="Horizontal" Width="100%"
CellPadding="2" CellSpacing="0">
<ItemTemplate>
<img src='<%# ((Imagez)Container.DataItem).URL
%>' style="border:1px solid gray;" /
>
</ItemTemplate>
</asp:DataList>
Here's the code behind:
public void GetImages()
{
int iCount;
List<Imagez> myImagez = new List<Imagez>();
for (iCount = 0; iCount <= 20; iCount++)
{
myImagez.Add(new Imagez());
myImagez[iCount].URL = @"http://mylink.com/image" +
iCount.ToString() + ".jpg";
}
dlThumbNails.DataSource = myImagez;
dlThumbNails.DataBind();
}
So now it works, the images appear in the DataList when this method
runs.
On Dec 19, 5:56 am, "Brandon Betances" <[email protected]> wrote:
> why are you setting the DataSource in code and in code-behind?