当前的一个项目,由于分页需再次查询一次SQL,感觉很慢,很不友好,于是采用空间换时间的方法,把数据写入Cache,感觉的确好很多,下面是源码~~ 分页主要使用 AspNetPager+ PagedDataSource+Cache DataTable result = new DataTable(); PagedDataSource pds = new PagedDataSource(); if (HttpContext.Current.Cache["pagerDataTable"] != null) { result = (DataTable)HttpContext.Current.Cache["pagerDataTable"]; } else { result = BLL.GetResult(); //获取数据 HttpContext.Current.Cache["pagerDataTable"] = result; } AspNetPager1.RecordCount = result.Rows.Count; pds.AllowPaging = true; pds.PageSize = AspNetPager1.PageSize; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.DataSource = result.DefaultView; gvResult.DataSource = pds; gvResult.DataBind();