我有一个List<string>
想要绑定到我的ListView
.
下面是我的标记ListView
:
<asp:ListView ID="lvList" runat="server">
<LayoutTemplate>
<div id="Div1" runat="server">
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div id="Div2" runat="server">
<div ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval ("theList") %>'/>
</ItemTemplate>
</asp:ListView>
在我的代码隐藏中:
protected void Page_Load(object sender, EventArgs e)
{
List<string> theList = new List<string>();
//populate members of list
lvList.DataSource = theList;
lvList.DataBind();
}
错误信息:
System.Web.HttpException 未被用户代码处理
Message="DataBinding: 'System.String' 不包含名为 'theList' 的属性。"
我想我在这里做错了,有人可以告诉我吗?