全部,
我有一个包含以下列的网格视图。分页效果很好,但没有排序。每次单击“类别”列按类别排序时,我都会收到此错误:
没有为类型“ESA.Data.Models.Entity.Project”定义实例属性“Category.CategoryName”
此错误语句不正确,因为 gridview 能够正确显示列。
这是选择方法
public IQueryable<Project> getProjects()
{
ApplicationServices objServices = new ApplicationServices();
IQueryable<Project> lstProject;
lstProject = objServices.getProjects();
return lstProject;
}
有什么建议吗?
<asp:GridView ID="grdProject" runat="server" ShowHeader="true"
AutoGenerateColumns="false" CellPadding="2" CellSpacing="2"
ItemType="ESA.Data.Models.Entity.Project"
SelectMethod="getProjects"
DataKeyNames="ProjectID"
AllowSorting="true"
AllowPaging="true"
PageSize="5">
<Columns>
<asp:BoundField DataField="ProjectID" HeaderText="ID " ItemStyle-Width="10" />
<asp:BoundField DataField="Category.CategoryName" HeaderText="Category" SortExpression="Category.CategoryName" />
<asp:BoundField DataField="ProjectName" HeaderText="Project Name" ItemStyle-Width="300" />
<asp:BoundField DataField="Status.StatusName" HeaderText="Status" SortExpression="Status.StatusName" />
<asp:BoundField DataField="AddedByUser.UserName" HeaderText="Added By" ItemStyle-Width="120" />
<asp:BoundField DataField="AddedDate" HeaderText="Added Date" ItemStyle-Width="90" DataFormatString="{0:d}" />
</Columns>
</asp:GridView>