问题描述
我想要一个带:首页|上一页|下一页|尾页-共1页|正在第1页GO的分页代码?请高手指点谢谢~~~~~~
解决方案
解决方案二:
用AspNetPager可以,很简单的.找一个DLL直接可以使用.
解决方案三:
找一个源码或者例子也行,谢谢了
解决方案四:
我正在用的,参考一下,不要嫌我的代码太丑了-__-!!///<summary>///产生翻页导航HTML///</summary>///<paramname="totalEntries">条目总数</param>///<paramname="pageSize">页条目大小</param>///<paramname="currentPage">当前页码</param>///<paramname="navigationUrl">导航URL,如view.aspx?cat=aspx</param>///<paramname="classNameForInvalid">为无效导航元素添加CSS类名</param>///<returns>HTML代码</returns>publicstaticstringGeneralPageNavigation(inttotalEntries,intpageSize,intcurrentPage,stringfirstPageFormat,stringlastPageFormat,stringnextPageFormat,stringpreviousPageFormat,stringtotalPagesFormat,stringnowAtFormat,stringclassNameForInvalid){inttotalPages;StringBuildersbAll=newStringBuilder();/**两种情况*条目记录<=每页数量*/if(totalEntries<pageSize||totalEntries==pageSize){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">首页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">上一页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">下一页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">尾页</span>-共1页|正在第1页</span>");returnsbAll.ToString();}else{if(totalEntries%pageSize!=0)totalPages=totalEntries/pageSize+1;elsetotalPages=totalEntries/pageSize;sbAll.Append(string.Format(firstPageFormat,1));sbAll.Append("|");if(currentPage==1){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">上一页</span>|");}else{sbAll.Append(string.Format(previousPageFormat,currentPage-1));sbAll.Append("|");}//endofifif(currentPage<totalPages){sbAll.Append(string.Format(nextPageFormat,currentPage+1));sbAll.Append("|");}else{sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">下一页</span>|");}//endofifsbAll.Append(string.Format(lastPageFormat,totalPages));sbAll.Append(string.Format(totalPagesFormat,totalPages));sbAll.Append(string.Format(nowAtFormat,currentPage));returnsbAll.ToString();}//endofif}publicstaticstringGeneralPageNavigation(inttotalEntries,intpageSize,intcurrentPage,stringnavigationUrl,stringclassNameForInvalid,stringfirstPage,stringlastPage,stringpreviousPage,stringnextPage,stringtotalPagesFormat,stringnowAt){inttotalPages;StringBuildersbAll=newStringBuilder();/**两种情况*条目记录<=每页数量*/if(totalEntries<pageSize||totalEntries==pageSize){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(firstPage);sbAll.Append("</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(nextPage);sbAll.Append("</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(previousPage);sbAll.Append("</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(lastPage);sbAll.Append("</span>-");sbAll.Append(string.Format(totalPagesFormat,1));sbAll.Append(string.Format(nowAt,1));sbAll.Append("</span>");returnsbAll.ToString();}else{totalPages=totalEntries/pageSize+1;sbAll.Append("<ahref="");sbAll.Append(navigationUrl);sbAll.Append("&page=1">");sbAll.Append(firstPage);sbAll.Append("</a>|");if(currentPage==1){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(previousPage);sbAll.Append("</span>|");}else{sbAll.Append("<ahref="");sbAll.Append(navigationUrl);sbAll.Append("&page=");sbAll.Append(currentPage-1);sbAll.Append("">");sbAll.Append(previousPage);sbAll.Append("</a>|");}//endofifif(currentPage<totalPages){sbAll.Append("<ahref="");sbAll.Append(navigationUrl);sbAll.Append("&page=");sbAll.Append(currentPage+1);sbAll.Append("">");sbAll.Append(nextPage);sbAll.Append("</a>|");}else{sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">");sbAll.Append(nextPage);sbAll.Append("</span>|");}//endofifsbAll.Append("<ahref="");sbAll.Append(navigationUrl);sbAll.Append("&page=");sbAll.Append(totalPages);sbAll.Append("">");sbAll.Append(lastPage);sbAll.Append("</a>-");sbAll.Append(string.Format(totalPagesFormat,totalPages));sbAll.Append("|");sbAll.Append(string.Format(nowAt,currentPage));returnsbAll.ToString();}//endofif}
解决方案五:
AspNetPager没有上一页下一页Go经理说就要:首页上一页下一页尾页GO这样的
解决方案六:
///<summary>///产生翻页导航HTML///</summary>///<paramname="totalEntries">条目总数</param>///<paramname="pageSize">页条目大小</param>///<paramname="currentPage">当前页码</param>///<paramname="navigationUrl">导航URL,如view.aspx?cat=aspx</param>///<paramname="classNameForInvalid">为无效导航元素添加CSS类名</param>///<returns>HTML代码</returns>publicstaticstringGeneralPageNavigation(inttotalEntries,intpageSize,intcurrentPage,stringfirstPageFormat,stringlastPageFormat,stringnextPageFormat,stringpreviousPageFormat,stringtotalPagesFormat,stringnowAtFormat,stringclassNameForInvalid){inttotalPages;StringBuildersbAll=newStringBuilder();/**两种情况*条目记录<=每页数量*/if(totalEntries<pageSize||totalEntries==pageSize){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">首页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">上一页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">下一页</span>|<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">尾页</span>-共1页|正在第1页</span>");returnsbAll.ToString();}else{if(totalEntries%pageSize!=0)totalPages=totalEntries/pageSize+1;elsetotalPages=totalEntries/pageSize;sbAll.Append(string.Format(firstPageFormat,1));sbAll.Append("|");if(currentPage==1){sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">上一页</span>|");}else{sbAll.Append(string.Format(previousPageFormat,currentPage-1));sbAll.Append("|");}//endofifif(currentPage<totalPages){sbAll.Append(string.Format(nextPageFormat,currentPage+1));sbAll.Append("|");}else{sbAll.Append("<spanclass="");sbAll.Append(classNameForInvalid);sbAll.Append("">下一页</span>|");}//endofifsbAll.Append(string.Format(lastPageFormat,totalPages));sbAll.Append(string.Format(totalPagesFormat,totalPages));sbAll.Append(string.Format(nowAtFormat,currentPage));returnsbAll.ToString();}//endofif
解决方案七:
直接写一个分页存储过程,界面上摆上那个一个按钮就ok
解决方案八:
3楼的是不是重复了?
解决方案九:
晕,你不会吧"<<"换成"上一页"你要的在属性里面都可以设置出来的.好好看一下属性!!
解决方案十:
AspNetPage
解决方案十一:
AspNetPagerOK的...经理的毛病挺多的...
解决方案十二:
AspNetPager这么好的分页控件都不用,准备用什么啊
解决方案十三:
让你们经理给写一个.让大家看看,NND,刁难人呢!!!
解决方案十四:
TO:3楼的是不是重复了?-----------呵呵,那方法我写了三个重载,也不知道哪个好,效率不同,灵活程度不同.使用很简单的,你只要传递几个参数而已.直接跳转到第XX页是另外一段HTML+JS的.<inputtype="text"id="txtTargetPage"class="CText"onkeypress="if(event.keyCode==13){changePage('category.aspx?cat=<%=curCat%>',this.value);returnfalse;}"onmouseover='this.focus()'/><inputtype="button"value="GO"class="CButton"onclick="changePage('category.aspx?cat=<%=curCat%>',txtTargetPage.value)"/>[code][code=JScript]functionchangePage(sUrlPrefix,sTargetPage){if(!isNaN(sTargetPage))location.href=sUrlPrefix+"&page="+sTargetPage;}
解决方案十五:
GridView控件,前台<asp:GridViewID="GridView1"runat="server"AllowPaging="True"PageSize="20"OnPageIndexChanging="GridView1_PageIndexChanging"><Columns>......</Columns><pagertemplate><tablewidth="100%"><tr><tdstyle="text-align:right">第<asp:Labelid="lblPageIndex"runat="server"text='<%#((GridView)Container.Parent.Parent).PageIndex+1%>'/>页共/<asp:Labelid="lblPageCount"runat="server"text='<%#((GridView)Container.Parent.Parent).PageCount%>'/>页<asp:linkbuttonid="btnFirst"runat="server"causesvalidation="False"commandargument="First"commandname="Page"text="首页"/><asp:linkbuttonid="btnPrev"runat="server"causesvalidation="False"commandargument="Prev"commandname="Page"text="上一页"/><asp:linkbuttonid="btnNext"runat="server"causesvalidation="False"commandargument="Next"commandname="Page"text="下一页"/><asp:linkbuttonid="btnLast"runat="server"causesvalidation="False"commandargument="Last"commandname="Page"text="尾页"/><asp:textboxid="txtNewPageIndex"runat="server"width="20px"text='<%#((GridView)Container.Parent.Parent).PageIndex+1%>'/><asp:linkbuttonid="btnGo"runat="server"causesvalidation="False"commandargument="-1"commandname="Page"text="GO"/><!--heresettheCommandArgumentoftheGoButtonto'-1'astheflag--></td></tr></table></pagertemplate></asp:GridView>后台代码:protectedvoidGridView1_PageIndexChanging(objectsender,GridViewPageEventArgse){GridViewtheGrid=senderasGridView;//refertotheGridViewintnewPageIndex=0;if(-2==e.NewPageIndex){//whenclickthe"GO"ButtonTextBoxtxtNewPageIndex=null;//GridViewRowpagerRow=theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count-1]asGridViewRow;//refertoPagerTemplateGridViewRowpagerRow=theGrid.BottomPagerRow;//GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow或者TopPagerRow,当然还增加了HeaderRow和FooterRow//updatedat2006年6月21日3:15:33if(null!=pagerRow){txtNewPageIndex=pagerRow.FindControl("txtNewPageIndex")asTextBox;//refertotheTextBoxwiththeNewPageIndexvalue}if(null!=txtNewPageIndex){newPageIndex=int.Parse(txtNewPageIndex.Text)-1;//gettheNewPageIndex}}else{//whenclickthefirst,last,previousandnextButtonnewPageIndex=e.NewPageIndex;}//checktopreventformtheNewPageIndexoutoftherangenewPageIndex=newPageIndex<0?0:newPageIndex;newPageIndex=newPageIndex>=theGrid.PageCount?theGrid.PageCount-1:newPageIndex;//specifytheNewPageIndextheGrid.PageIndex=newPageIndex;DataSetds=this.getData();//获得数据源DataSettheGrid.DataSource=ds;//重新绑定theGrid.DataBind();//rebindthecontrol//inthiscaseofretrievingthedatausingthexxxDataSoucrcontrol,//justdonothing,becausetheasp.netenginebindsthedataautomatically}