【问题标题】:ASP.NET Webforms - JQGrid Populate Data with ObjectDataSource (Object in Object)ASP.NET Webforms - JQGrid 使用 ObjectDataSource 填充数据(对象中的对象)
【发布时间】:2013-05-06 09:33:37
【问题描述】:

这是我对 JQGrid 的尝试:

<JQ:JQGridColumn 
                DataField="ID" 
                PrimaryKey="true"
                DataType="int"
                HeaderText="NO" 
                Width="60" />
            <JQ:JQGridColumn 
                DataField="CustomerID.Name"
                DataType="String"
                HeaderText="Customer Name" 
                Width="100" />
            <JQ:JQGridColumn 
                DataField="CustomerID.Surname" 
                Searchable="false"
                DataType="String"
                HeaderText="Customer Surname 
                Width="100" />

而 ObjectDataSource 类是:

public class Order
{
private int iD;
private Customer customerID;

public Customer CustomerID
        {
            get { return customerID; }
            set { customerID = value; }
        }

        public int ID
        {
            get { return iD; }
            set { iD = value; }
        }
}

Customer 类就像 Order 类。所以当我尝试这样做时,它给出了那个错误:

DataField=CustomerID.Name 的列在数据源中不存在。(但确实存在)

我该如何解决?谢谢。

【问题讨论】:

    标签: asp.net jqgrid webforms objectdatasource jqgrid-asp.net


    【解决方案1】:

    我有答案了:

    public string CustomerName
            {
                get { return CustomerID == null ? "" : CustomerID.Name; }
            }
    

    如果有人需要,请使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 2017-02-10
      • 1970-01-01
      相关资源
      最近更新 更多