protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int totalRows = 0; GridView1.DataSource = UserDataAccessLayer.GetUsers(0, GridView1.PageSize, GridView1.Attributes["CustomSortField"], GridView1.Attributes["CustomSortDirection"], out totalRows); GridView1.DataBind(); DataBindRepeater(0, GridView1.PageSize, totalRows); } }
protected void linkButton_Click(object sender, EventArgs e) { int totalRows = 0; int pageIndex = int.Parse((sender as LinkButton).CommandArgument); pageIndex -= 1; GridView1.PageIndex = pageIndex; GridView1.DataSource = UserDataAccessLayer.GetUsers(pageIndex, GridView1.PageSize, GridView1.Attributes["CustomSortField"], GridView1.Attributes["CustomSortDirection"], out totalRows); GridView1.DataBind(); DataBindRepeater(pageIndex, GridView1.PageSize, totalRows); }
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { SortDirection sortDirection = SortDirection.Ascending; string sortField = string.Empty; SortGridview(GridView1, e, out sortDirection, out sortField); string strSortDirection = sortDirection == SortDirection.Ascending ? "ASC" : "DESC"; int totalRows = 0; GridView1.DataSource = UserDataAccessLayer.GetUsers(GridView1.PageIndex, GridView1.PageSize, e.SortExpression, strSortDirection, out totalRows); GridView1.DataBind(); DataBindRepeater(GridView1.PageIndex, GridView1.PageSize, totalRows); }