我运行此事件处理程序和方法进行梳理我的GridView控件,但最高审计机关,它是空:排序后GridView变为NULL?
protected void OtherGridView_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dtSortTable = gvMeldingen.DataSource as DataTable;
DataView dvSortedView = new DataView(dtSortTable);
dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection);
gvMeldingen.DataSource = dvSortedView;
gvMeldingen.DataBind();
}
private string getSortDirectionString(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
if (sortDirection == SortDirection.Ascending)
{
newSortDirection = "ASC";
}
else
{
newSortDirection = "DESC";
}
return newSortDirection;
}
请帮助我。先谢谢你!
这是我得到的错误:在使用DataView之前必须设置DataTable。
这凸显:dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection)
是dtSortaTable空每次设置DataSource?您能否在页面的Load事件中发布代码? – Larry 2011-05-09 07:25:57
有没有加载事件 – SamekaTV 2011-05-09 07:27:08
我得到这个错误:DataTable必须在使用DataView之前设置。 并突出显示:dvSortedView.Sort = e.SortExpression +“”+ getSortDirectionString(e.SortDirection); – SamekaTV 2011-05-09 07:28:35