protected void gridview1_Sorting(object sender, GridViewSortEventArgs e)
{
SortDirection sort;
string f;
GridViewSortDirection(example, e, out sort, out f);
if (sort == SortDirection.Ascending)
{
**gridview.datasource = ascendinge göre verileri çekin;
}
else
{
**gridview.datasource = descendinge göre verileri çekin;
}
**gridview.DataBind();
}
private void GridViewSortDirection(GridView g, GridViewSortEventArgs e, out SortDirection d, out string f)
{
f = e.SortExpression;
d = e.SortDirection;
if (f == g.Attributes["CurrentSortField"])
{
d = SortDirection.Descending;
if (g.Attributes["CurrentSortDir"] == "ASC")
{
d = SortDirection.Ascending;
}
}
g.Attributes["CurrentSortField"] = f;
g.Attributes["CurrentSortDir"] = (d == SortDirection.Ascending ? "DESC" : "ASC");
}