gpt4 book ai didi

c# - 将列表 <> 绑定(bind)到 asp.net c# 中的 ListView

转载 作者:太空狗 更新时间:2023-10-29 18:22:42 26 4
gpt4 key购买 nike

我有以下代码:

<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();

但是我在绑定(bind)时遇到了以下错误:

<td><%# Eval("ShpNo")%></td>

DataBinding: 'AIS.WebVisibility+Visibility' does not contain a property with the name 'ShpNo'.

我需要做什么才能从列表中获取正确的值?

最佳答案

你有字段,而不是属性

public class Visibility
{
public int ShpNo { get; set; }
public int QtyShp { get; set; }
public int NumPallets { get; set; }
public string ETA { get; set; }
}

试试看

关于c# - 将列表 <> 绑定(bind)到 asp.net c# 中的 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13613856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com