Thanks for your reply Victor,
Well, I've performed some local test through the custom control you
provided. It seems I can correctly make the "MyControl" display image
(through databinding) well in DataList. I think there might be something
incorrect with your aspx template of the DataList, would you also provide
it so that we can have a check? Anyway, below is my test page's aspx
template and code behind for your reference:
===========aspx================
<asp

ataList ID="DataList1" runat="server">
<ItemTemplate>
MYControl:
<cc1:MyControl ID="MyControl1" runat="server"
ImagePath='<%# Eval("ImagePath") %>' />
</ItemTemplate>
</asp

ataList>
========code behind============
protected void Page_Load(object sender, EventArgs e)
{
BindList();
}
protected void BindList()
{
MyControl[] mcs = new MyControl[5];
for (int i = 0; i < mcs.Length; i++)
{
mcs[i] = new MyControl();
mcs[i].ID = "mc_" + i;
mcs[i].MyControlID = i;
mcs[i].ImagePath =
"http://static.asp.net/asp.net/images/MicrosoftASPNET.gif";
}
DataList1.DataSource = mcs;
DataList1.DataBind();
}
=============================
the "MyControl"'s code is identical to yours. If you have any questions on
this, please feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.