{
string sqlQuery = "SELECT data from datatable";
DataTable resultTable = getDataTable(sqlQuery, 4);
DataView dv = new DataView(resultTable);
if (ViewState["sortExpr"] != null)
{
dv.Sort = (string)ViewState["sortExpr"] + " " + sortingOrder;
}
gvShowCoursesInstitution.DataSource = dv;
gvShowCoursesInstitution.DataBind();
dv.Dispose();
resultTable.Dispose();
}
protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
{
ViewState["sortExpr"] = e.SortExpression;
bindInstitutionCourses();
}
private string sortingOrder
{
get
{
if (ViewState["sortingOrder"] != null)
{
if (ViewState["sortingOrder"].ToString() == "desc")
{
ViewState["sortingOrder"] = "asc";
}
else
{
ViewState["sortingOrder"] = "desc";
}
}
else
{
ViewState["sortingOrder"] = "desc";
}
return ViewState["sortingOrder"].ToString();
}
set
{
ViewState["sortingOrder"] = value;
}
}
No comments:
Post a Comment