protected void gvUserInfo_Sorting(object sender, GridViewSortEventArgs e) { GridViewSortExpression = e.SortExpression; int pageIndex = 0; gvUserInfo.DataSource = SortDataTable(AccountData.GetUserInfo(), false); gvUserInfo.DataBind(); gvUserInfo.PageIndex = pageIndex; }
protected void BindUserInfo() { try { if (Session["SortExp"] == null) { gvUserInfo.DataSource = AccountData.GetUserInfo(); gvUserInfo.DataBind(); } else { DataTable table = AccountData.GetUserInfo(); DataView view = table.DefaultView; view.Sort = Session["SortExp"].ToString(); gvUserInfo.DataSource = view.ToTable(); gvUserInfo.DataBind(); } } catch (Exception ex) { lblErrorMsg.Text = ex.Message; } }