我想呈現一些aspx頁面上的圖像。C#通用列表和ASP轉發器樂趣
錯誤我在下面的代碼中得到的是:DataBinding:'_Default + ImageThing'不包含名稱爲'FileName'的屬性。
public class ImageThing
{
public string FileName;
}
private void DisplayThumbnailImages()
{
ImageThing imageThing1 = new ImageThing();
ImageThing imageThing2 = new ImageThing();
imageThing1.FileName = "asdf.jpg";
imageThing2.FileName = "aaa.jpg";
List<ImageThing> imagesToRender = new List<ImageThing>();
imagesToRender.Add(imageThing1);
imagesToRender.Add(imageThing2);
Repeater1.DataSource = imagesToRender;
Repeater1.DataBind();
}
這裏是ASPX:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
</ItemTemplate>
</asp:Repeater>
感謝
Dangit!你擊敗了我。 :) +1 – 2010-08-04 22:54:11
多數民衆贊成 - 歡呼斯科特,和djacobson太:-) – 2010-08-04 22:56:22