나는 나의의 GridView를 정렬하려면이 이벤트 핸들러 및 방법을 실행하지만, 그것이 null이 있다고 SAIS :정렬 후 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;
}
저를 도와주세요. 미리 감사드립니다.
이것은 내가 얻은 오류입니다. DataTable은 DataView를 사용하기 전에 설정해야합니다.
그리고이 강조 :dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection)
이 dtSortaTable null의 각 시간을 설정하는 것입니다
해결책은 아래에 데이터 소스 다시 쿼리입니까? 페이지의 Load 이벤트에 코드를 게시 할 수 있습니까? – Larry
로드 이벤트 없음 – SamekaTV
이 오류가 발생합니다. DataTable은 DataView를 사용하기 전에 설정해야합니다. 및이 강조 표시 : dvSortedView.Sort = e.SortExpression + ""+ getSortDirectionString (e.SortDirection); – SamekaTV