如何在asp.net中自定义一个分页控件

  介绍

这期内容当中小编将会给大家带来有关如何在asp.net中自定义一个分页控件,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

一、.ascx页面

& lt; % @  Control 语言=癱#“, AutoEventWireup=皌rue",后台代码=癙agination.ascx.cs",继承=癐OCS.WEB.UserControl.Pagination", %比;   https://www.yisu.com/zixun/& lt; link  href=" . ./内容/Css/Pager.css”rel="样式表" type=" text/Css "/>   
  記錄總數:   總頁數:   當前頁:               轉到第

二,.ascx。cs文件

using 系统;using  System.Collections.Generic; using 来;using 包含;using  System.Web.UI; using  System.Web.UI.WebControls;   namespace  IOCS.WEB.UserControl {,,, public  partial  class  Pagination :, System.Web.UI.UserControl ,,, {,,,,,,, public  event  EventHandler  PageButtonClick;,,,,,,,, public  bool  FirstPost =,假的,,,,,,,,,protected  void  employee (object ,发送方,EventArgs  e),,,,,,,, {,,,,,,,,,,, if  (! IsPostBack),,,,,,,,,,,, {,,,,,,,,,,,,,   ,,,,,,,,,,,},,,,,,,,,,,,//,只輸入數字,,,,,,,,,,,,txtpage.Attributes.Add (“onclick",,,,,,,,,,,,,,,,, @"如果(! ((event.keyCode>=48,, event.keyCode<=57),,,,,,,,,,,,,,,,,,,, | | (event.keyCode>=96,, event.keyCode<=105),,,,,,,,,,,,,,,,,,,, | | (event.keyCode==8))) event.returnValue=https://www.yisu.com/zixun/false;”);   GridView _gv};///<总结>///需要分頁的显示数据表格///> 0) {_gv.PageIndex——;}打破;}案例(“第一”):{_gv。PageIndex=0;打破;}案例(“最后”):{如果(_gv。PageCount> 0) {_gv。PageIndex=_gv。PageCount - 1;}打破;}   默认值:{_gv。PageIndex=Convert.ToInt32 (arg);打破;}}PageButtonClick(发送方,e);   }      {如果(_gv公共空间SetPageButton ()。{LinkFirst PageIndex==0)。启用=false;LinkPrevious。启用=false;   LinkFirst。风格(“颜色”)=盎疑?LinkPrevious。null   null   null   null   null   null

如何在asp.net中自定义一个分页控件