<asp:GridView ID="GridPayCondition" Width="750px" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" AllowSorting="True" OnRowDataBound="GridPayCondition_RowDataBound" AllowPaging="True" OnPageIndexChanging="GridPayCondition_PageIndexChanging" OnSorting="GridPayCondition_Sorting" >
aspx文件的代碼:CS文件的
我使用列表獲取「數據源不支持服務器端數據分頁」的錯誤排序的GridView數據@ jordanArron
代碼:
protected void GridPayCondition_Sorting(object sender, GridViewSortEventArgs e)
{
List<PayCondition> paycondition = new List<PayCondition>();
EditPayConditionLogic epcLogic = new EditPayConditionLogic();
paycondition = epcLogic.GetPayCondition();
if(paycondition!=null)
{
var param = Expression.Parameter(typeof(PayCondition), e.SortExpression);
var sortExpression = Expression.Lambda<Func<PayCondition, object>>(Expression.Convert(Expression.Property(param, e.SortExpression), typeof(object)), param);
if(ViewState["SortDirection"]=="DESC")
{
ViewState["SortDirection"] = "ASC";
GridPayCondition.DataSource = paycondition.AsQueryable<PayCondition>().OrderBy(sortExpression);
}
else
{
ViewState["SortDirection"] = "DESC";
GridPayCondition.DataSource = paycondition.AsQueryable<PayCondition>().OrderByDescending(sortExpression);
}
GridPayCondition.DataBind();
}
}
#jordanArron請幫助我關於你post.I上午初學者所以不能聯合國明確此異常 – ashT
SO通常不會通過詢問特定人員的幫助來運作;相反,可以鏈接到任何你需要的背景問題,或者最好只是解釋你需要什麼,這樣任何有足夠專業知識的人都可以回答。 –
我是完全新的stackoverflow,謝謝你的指導。 – ashT