8

我有以下代码:

<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'.

为了从列表中获取正确的值,我需要做什么?

4

1 回答 1

12

你有字段,而不是属性

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

试试看

于 2012-11-28T20:33:35.667 回答