protected void Gridview_Partment_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView theGrid = sender as GridView; // refer to the GridView int newPageIndex = 0; if (-2 == e.NewPageIndex) { TextBox txtNewPageIndex = null; GridViewRow pagerRow = Gridview_Organization.BottomPagerRow; if (null != pagerRow) { txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox"); // refer to the TextBox with the NewPageIndex value } if (null != txtNewPageIndex && txtNewPageIndex.Text != "") { newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex } } else { newPageIndex = e.NewPageIndex; } string condition = GetDepartment(); Gridview_Organization.DataSource = prmps.SelectPRMP_Organization(condition); Gridview_Organization.DataBind(); newPageIndex = newPageIndex < 0 ? 0 : newPageIndex; newPageIndex = newPageIndex >= Gridview_Organization.PageCount ? Gridview_Organization.PageCount - 1 : newPageIndex; Gridview_Organization.PageIndex = newPageIndex; Gridview_Organization.DataBind(); }
//显示所有部门 private void BindGridView_Organizationinfo(string condition) { try { //this.Gridview_Organization.Columns.Clear(); Gridview_Organization.DataSource = prmps.SelectPRMP_Organization(condition); Gridview_Organization.DataBind(); } catch (Exception ex) { throw ex; } }