Код: Выделить всё
protected void gvEmployeeStatus_Sorting(object sender, GridViewSortEventArgs e)
{
loginName = (String)(Session["LoginName"]);
dsLoginDetail = clsBLogic.TblLogin(loginName);
tblEmployeeNo = dsLoginDetail.Tables[0].Rows[0]["EmployeeNo"].ToString();
BindDataTogvEmployeeStatus(tblEmployeeNo);
DataTable dataTable = gvEmployeeStatus.DataSource as DataTable;
if(dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.Sort = e.SortExpression + " " + ConvertSortDirection(e.SortDirection);
gvEmployeeStatus.DataSource = dataView;
gvEmployeeStatus.DataBind();
}
}
private string ConvertSortDirection(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;
case SortDirection.Descending:
newSortDirection = "DESC";
break;
}
return newSortDirection;
}
Подробнее здесь: https://stackoverflow.com/questions/243 ... f-a-column
Мобильная версия