这样得gridview分页如何实现?

sickcatzzzz 2009-01-23 11:46:57
共7页 << < ... [1] [2] [3] [4] [5] ... > >> 7字还要红色得。。
我是gridview直接绑定的ObjectDataSource控件
然后控件执行OnPageIndexChanging="GridView1_PageIndexChanging" 调用DAL层得linq。

请大家给详细说说,没搞过这个谢谢了!
...全文
6882 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
jason87629 2011-02-24
  • 打赏
  • 举报
回复
学习了,谢谢!!!!刚要做分页
swalp 2010-04-30
  • 打赏
  • 举报
回复
留个位置,一会回去看!!!
颠倒的企鹅 2009-11-09
  • 打赏
  • 举报
回复
有个第三方空间,去下载一个,就是这样分的
happyLouise1 2009-07-07
  • 打赏
  • 举报
回复
用 AspNetPager控件可以达到,怎么实现的看代码



this.AspNetPager1.RecordCount = dt.Rows.Count;
this.AspNetPager1.PageSize = this.GridView1.PageSize;
this.AspNetPager1.CustomInfoText = "<span class=mytext>记录总数:<font color=\"black\"><b>" + this.AspNetPager1.RecordCount.ToString() + "</b></font></span>  ";
this.AspNetPager1.CustomInfoText = this.AspNetPager1.CustomInfoText + "<span class=mytext>总页数:<font color=\"black\"><b>" + this.AspNetPager1.PageCount.ToString() + "</b></font></span>  ";
this.AspNetPager1.CustomInfoText = this.AspNetPager1.CustomInfoText + "<span class=mytext>当前页:<font color=\"black\"><b>" + this.AspNetPager1.CurrentPageIndex.ToString() + "</b></font></span>  ";
this.AspNetPager1.CurrentPageIndex = 1;
maminglong 2009-06-29
  • 打赏
  • 举报
回复
学习
x343689970 2009-06-26
  • 打赏
  • 举报
回复
fds
sheixiu 2009-02-01
  • 打赏
  • 举报
回复
直接给你贴出来。
前台:
<webdiyer:aspnetpager id="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged"
showcustominfosection="Left" width="100%" CustomInfoHTML=" 共%PageCount%页"
PageIndexBoxStyle="width:19px" NumericButtonCount="5" PageSize="8"
PagingButtonSpacing="8px" PagingButtonStyle=""></webdiyer:aspnetpager>
后台

public void bindData()
{
using (OfficeChannel.OfficeChannelDataContext ocDC = new OfficeChannel.OfficeChannelDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString))
{
var DL = from cd in ocDC.Class_Download
//where cd.UserID == UserID

join cl in ocDC.Class on cd.classID equals cl.classID
join ct in ocDC.Class_Type on cl.classTypeID equals ct.classTypeID
select new
{

downloadTime = cd.DownloadTime,
classtitle = cl.classTitle,
classtype = ct.classType.Replace("Microsoft ", ""),
releasetime = cl.releaseTime,
ClassID = cl.classID,
ClassType = cl.classBigTypeID

};

var dl = DL.Skip(AspNetPager1.StartRecordIndex).Take(AspNetPager1.EndRecordIndex - AspNetPager1.StartRecordIndex + 1);


GridView1.DataSource = dl;

GridView1.DataBind();

}
}
liujiayu10 2009-01-23
  • 打赏
  • 举报
回复
绑定的话,可以用AspNetPager.dll

否则可以用JS

Page.js 一搜一堆呢
homesos 2009-01-23
  • 打赏
  • 举报
回复
可以去 www.codeproject.com
下载开源的分页控件,应该有你想要的,也可以自己改改用。
cwmwss 2009-01-23
  • 打赏
  • 举报
回复
JS
sheixiu 2009-01-23
  • 打赏
  • 举报
回复
<PagerTemplate>
<asp:Label ID="LabelCurrentPage" runat="server" Text=" <%# ((GridView)Container.NamingContainer).PageIndex + 1 %> "> </asp:Label>
<%--(2) 总页数 --%>
<asp:Label ID="LabelPageCount" runat="server" Text=" <%# ((GridView)Container.NamingContainer).PageCount %> "> </asp:Label>
<%--(3) 首页、上一页、下一页、尾页 --%>
<asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First "
CommandName="Page " Visible=" <%# ((GridView)Container.NamingContainer).PageIndex != 0 %> "> << </asp:LinkButton>
<asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev "
CommandName="Page " Visible=" <%# ((GridView)Container.NamingContainer).PageIndex != 0 %> "> < </asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next " CommandName="Page "
Visible=" <%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %> "> > </asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last " CommandName="Page "
Visible=" <%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %> "> >> </asp:LinkButton>
</PagerTemplate>


给你做个参考吧,应该有更好控件得。
koukoujiayi 2009-01-23
  • 打赏
  • 举报
回复
如果数据量不大的话,就用GridView自带的分页功能,
一句代码都不要!!
在GridView的属性上设置,
即设置GridView的AllowPaging为true即可!!!
格式设置也在属性面板上,
即GridView的PagerSettings中!!
sickcatzzzz 2009-01-23
  • 打赏
  • 举报
回复
对啊 我想弄成共7页 < < < ... [1] [2] [3] [4] [5] ... > >> 的样式。。。
zhxhdean 2009-01-23
  • 打赏
  • 举报
回复
gridview 本身就支持分页的
sickcatzzzz 2009-01-23
  • 打赏
  • 举报
回复
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber");
AspNetPager1.RecordCount = totalOrders;
bindData();
}
}

void bindData()
{
DataList1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"],
new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex),
new SqlParameter("@endIndex", AspNetPager1.EndRecordIndex));
DataList1.DataBind();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
bindData();
}

这是AspNetPager控件 以下两句在linq中怎么实现呢?
new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex),
new SqlParameter("@endIndex", AspNetPager1.EndRecordIndex));
jin225 2009-01-23
  • 打赏
  • 举报
回复
自动分页好想没有 那样的样式
successful_cdr 2009-01-23
  • 打赏
  • 举报
回复
sickcatzzzz 2009-01-23
  • 打赏
  • 举报
回复
哦。。。其实我问得主要是样式问题。。。。
错误 2 “System.Web.UI.HtmlControls.HtmlGenericControl”不包含“RecordCount”的定义,并且找不到可接受类型为“System.Web.UI.HtmlControls.HtmlGenericControl”的第一个参数的扩展方法“RecordCount”(是否缺少 using 指令或程序集引用?) D:\OC三层框架 linq\OfficeChannel\UserCenter\User_manage_moviedown.aspx.cs 116 26 OfficeChannel

还报错。。。。
rascalwm 2009-01-23
  • 打赏
  • 举报
回复
用自带的分页功能 或者用 pagedatasource 这个类去分页
wjfmail 2009-01-23
  • 打赏
  • 举报
回复
返回只要是list<obj>这样的形式 ,本身就支持分页阿.不用写任何东西.
加载更多回复(1)

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧