/// <summary> /// 绑定数据源 /// </summary> private void bind() { Label_className.Text = DropDownList_class.SelectedValue; CommonBLL commonBLL = new CommonBLL(); string filter = "1=1 "; filter += DropDownList_class.SelectedValue.Equals("全院") ? "" : " and className='" + DropDownList_class.SelectedValue + "'"; string sort = "stuId"; DataTable dt = PageUtil.getProcessedDataTable(commonBLL.getStudents(), filter, sort); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.getPaged(dt, from, to); GridView1.DataBind(); }