【Linq to SharePoint】对列表查询的分页技术
2012-01-30 09:19
330 查看
1. 下面是用AspNetPage来分页的,主要在网站在有一个列表名称为新闻列表,BindGridView是一个分页的函数。
下面的主要是对一个列表的查询进行的分页。
后台代码
前台代码:
下面的主要是对一个列表的查询进行的分页。
后台代码
EntityList<新闻列表项目> newsList; public const int PageSize = 10; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindGridView(GridView1.PageSize, 1); } } /// <summary> /// 绑定GridView控件 /// </summary> /// <param name="pagesize">一页的条数</param> /// <param name="pageindex">页码数</param> protected void BindGridView(int pagesize, int pageindex) { var dc = new SPLinqDataContext(SPContext.Current.Web.Url); newsList = dc.GetList<新闻列表项目>("新闻列表"); GridView1.PageSize = PageSize; AspNetPager1.PageSize = PageSize; var q = (from n in newsList where n.Id != null select new { n.Id,n.点击次数, n.标题 }) .Skip((pageindex - 1) * PageSize).Take(PageSize); AspNetPager1.RecordCount = q.Count(); GridView1.DataSource = q; GridView1.DataBind(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { GridView1.PageIndex = AspNetPager1.CurrentPageIndex; BindGridView(GridView1.PageSize, AspNetPager1.CurrentPageIndex); }
前台代码:
<div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> <div> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageIndexBoxType="DropDownList" ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" CurrentPageButtonPosition="End" CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" OnPageChanged="Pager_PageChanged" PrevPageText="上一页"> </webdiyer:AspNetPager> </div>
相关文章推荐
- 【Linq to SharePoint】对列表查询的分页技术制作新联列表分页
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(1.通过BCS创建External List)
- SPList--使用Linq to Sharepoint间接查询External List(3.使用Linq to Sharepoint查询List内容)
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(2.复制External List内容)
- Linq to SharePoint中一个列表包含多个Content Type问题
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(3.使用Linq to Sharepoint查询List内容)
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(3.使用Linq to Sharepoint查询List内容)
- 如何:使用 LINQ to SharePoint 进行查询
- linq to sql 分页技术
- Sharepoint list 自定义分页与GotoPage solution
- Linq to SharePoint 之 parameters的使用
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- Linq to Sharepoint(转)
- 在SharePoint Designer 2007中使用交叉列表查询的数据视图
- 转:C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- moss 2010 linq to sharepoint
- MOSS 2010:Visual Studio 2010开发体验(15)——LINQ to SharePoint
- SP 2010: Getting started with LINQ to SharePoint in SharePoint 2010
- Sharepoint学习笔记---Linq to Sharepoint--如何获取Linq Query 生成的CALM