7
我有以下代碼:綁定一個List <>在asp.net C#列表視圖
<asp:ListView ID="lvDetail" runat="server">
<ItemTemplate>
<tr>
<td><%# Eval("ShpNo")%></td>
<td><%# Eval("QtyShp")%></td>
<td><%# Eval("NumPallets")%></td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="tbl1" runat="server">
<tr id="tr1" runat="server">
<td id="td1" runat="server">ShpNo</td>
<td id="td2" runat="server">QtyShp</td>
<td id="td3" runat="server">NumPallets</td>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
而且在後面的代碼:
List<Visibility> ListVisibility = new List<Visibility>();
public class Visibility
{
public int ShpNo;
public int QtyShp;
public int NumPallets;
public string ETA;
}
List<Visibility> items = ListVisibility.FindAll(VisibItem => VisibItem.ETA == Calendar1.SelectedDate.ToShortDateString());
lvDetail.DataSource = items;
lvDetail.DataBind();
,但我發現了以下錯誤當綁定:
<td><%# Eval("ShpNo")%></td>
DataBinding: 'AIS.WebVisibility+Visibility' does not contain a property with the name 'ShpNo'.
我需要做什麼才能從列表中獲得正確的值?
那麼該錯誤消息指出它無法找到,例如場起,「ShpNo」 * *財產。也許自動聯編程序不能在公共*字段*上工作,就像您一樣。一個屬性看起來像這樣:'public int ShpNo {get;組; }' –
謝謝科裏:) – Somebody