int pageoffset=midpage*NumericButtonCount; int endpage=((pageoffset+NumericButtonCount)>PageCount)?PageCount:(pageoffset+NumericButtonCount); this.CreateNavigationButton(writer,"first"); this.CreateNavigationButton(writer,"prev"); if(ShowPageIndex) { if(CurrentPageIndex>NumericButtonCount) CreateMoreButton(writer,pageoffset); for(int i=pageoffset+1;i<=endpage;i++) { CreateNumericButton(writer,i); } if(PageCount>NumericButtonCount&&endpage<PageCount) CreateMoreButton(writer,endpage+1); } this.CreateNavigationButton(writer,"next"); this.CreateNavigationButton(writer,"last"); if((ShowInputBox==ShowInputBox.Always)(ShowInputBox==ShowInputBox.Auto&&PageCount>=ShowBoxThreshold)) { writer.Write(" "); if(TextBeforeInputBox!=null) writer.Write(TextBeforeInputBox); writer.AddAttribute(HtmlTextWriterAttribute.Type,"text"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width,"30px"); writer.AddAttribute(HtmlTextWriterAttribute.Value,CurrentPageIndex.ToString()); if(InputBoxStyle!=null&&InputBoxStyle.Trim().Length>0) writer.AddAttribute(HtmlTextWriterAttribute.Style,InputBoxStyle); if(InputBoxClass!=null&&InputBoxClass.Trim().Length>0) writer.AddAttribute(HtmlTextWriterAttribute.Class,InputBoxClass); if(PageCount<=1&&AlwaysShow) writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly,"true"); writer.AddAttribute(HtmlTextWriterAttribute.Name,this.UniqueID+"_input"); string scriptRef="doCheck(document.all['"+this.UniqueID+"_input'])"; string postRef="if(event.keyCode==13){if("+scriptRef+")__doPostBack('"+this.UniqueID+"',document.all['"+this.UniqueID+"_input'].value);else{event.returnValue=false;}}"; string keydownScript="if(event.keyCode==13){if("+scriptRef+"){even
csover 发表于:2006.07.21 08:46 ::分类: ( asp.net ) ::阅读:(464次) :: 评论 (0) :: 引用 (0) 2006 年 07 月 20日, 星期四 一个简单的分页控件 采用Datagrid的默任的分页方式分页,后来发现对于大的数据量速度很慢,NET进程占用系统资源也很大,后来写了个分页的存储过程,每次取数据都只取当前页的,分页是分好了,但是发现翻页就没那么方便了,于是自己写了个简单的分页控件,代码如下(编译以后直接形成dll就可以用)。 sample code: using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace PageInfoControl { ///<summary> ///WebCustomeControl1的摘要说明 ///</summary> [DefaultProperty('TotalRecord'),ToolboxData('<{0}:PageInfo runat=server></{0}:PageInfo>')] public class PageInfo:System.Web.UI.WebControls.WebControl,IPostBackEventHandler
上一篇:SQL Server加密与SQL注入
下一篇:ASP无法更新ACCESS数据库解决方法
|