//查数据库使用Linq表达式 /// /// 分页获取数据 /// /// /// /// /// /// public static IList GetListPage(int PageIndex, int PageSize, out int total) { try { using (CertDataContext cdc = new CertDataContext(Tool.sqlstr)) { total = cdc.c_operator.Count(); return cdc.c_operator.Skip(PageIndex * PageSize).Take(PageSize).ToList(); } } catch (Exception) { total = 0; return null; } } //GriedView绑定数据源 public void gvBind() { int count = 0; this.GridView1.DataSource = DepartmentBLL.GetAll(Pager1.PageIndex, Pager1.PageSize, out count); this.GridView1.DataBind(); Pager1.ItemCount = count; if (count > Pager1.PageSize) { Pager1.Visible = true; } else Pager1.Visible = false; }