protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (ViewState["order"] == null)
{
ViewState["order"] = "ASC";
}
else
{
if (ViewState["order"].ToString () == "ASC")
{
ViewState["order"] = "DESC";
}
else
{
ViewState["order"] ="ASC";
}
}
SqlConnection con = DB.createCon();
con.Open();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from city", con);
DataSet ds = new DataSet();
sda.Fill(ds, "province");
ds.Tables["province"].DefaultView.Sort = e.SortExpression + " " + ViewState["order"].ToString ();
this.GridView1.DataSource = ds.Tables["province"].DefaultView ;
this.GridView1.DataBind();
}