모델 바인딩을 사용하여 일부 데이터를 표시하는 데 Listview를 사용하고 있으며 데이터 원본의 외래 키 열과 관련된 목록 뷰의 열을 정렬하려고합니다. 즉 책 열. 다음과 같이모델 바운드 목록보기의 외래 키 열 정렬
는 데이터 모델은 다음과 같습니다
public class Book
{
public Book() {
this.Factions = new HashSet<Faction>();
}
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Title { get; set; }
public virtual ICollection<Faction> Factions { get; set; }
}
public class Faction
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(10)]
public string Abbreviation { get; set; }
public int? BookId { get; set; }
public virtual Book Book { get; set; }
}
을 그리고 이것은 내가 오류 책의 LinkButton을 클릭하면
<asp:ListView ID="FactionListView" runat="server"
ItemType="DCW.Models.Faction" DataKeyNames="Id"
SelectMethod="FactionGetData"
<LayoutTemplate>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>
<asp:LinkButton ID="FactionListViewName" runat="server" CommandName="Sort"
CommandArgument="Name">Name</asp:LinkButton></th>
<th>
<asp:LinkButton ID="FactionListViewAbbreviation" runat="server" CommandName="Sort"
CommandArgument="Abbreviation">Abbreviation</asp:LinkButton></th>
<th>
<asp:LinkButton ID="FactionListViewBook" runat="server" CommandName="Sort"
CommandArgument="Book">Book</asp:LinkButton></th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
을 ListItem
의 제목을 표시하는 HTML입니다 : sys 인을. WebForms.PageRequestManagerServerErrorException : DbSortClause 식은 순서가 비슷한 형식이어야합니다.Link.Button CommandArgument를 Book.Id 또는 it.Book.Title (일부 다른 게시물에서 읽은 것)으로 변경하면 오류가 발생합니다. Sys.WebForms.PageRequestManagerServerErrorException : 예외가 발생했습니다. 호출의 타겟
그래서 Model Bound Listview의 관련 열을 정렬하려면 어떻게해야합니까?
감사합니다.