0
請幫幫我。我已經使用list daatsource創建了gridview。我想爲gridview應用排序事件來對所有列進行排序。Gridview的手動排序事件
這裏是我的代碼:
保護無效grduAdminSerservice_Sorting(對象發件人,GridViewSortEventArgs E) {
DataTable tbl = grduAdminSerservice.DataSource as DataTable;
if (tbl != null)
{
DataView dv = new DataView(tbl);
dv.Sort = e.SortExpression + "" + getSortDirectionString(e.SortDirection);
grduAdminSerservice.DataSource = dv;
grduAdminSerservice.DataBind();
}
}
private string getSortDirectionString(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
if(sortDirection== SortDirection.Ascending)
{
newSortDirection = "ASC";
}
else
{
newSortDirection = "DESC";
}
return newSortDirection;
}
........
但表只得到空值。如何將gridview源代碼綁定到表。請幫我