JavaShuo
欄目
標籤
AspnetPage分頁控件
時間 2019-11-09
標籤
aspnetpage
分頁
控件
简体版
原文
原文鏈接
AspNetPager分頁控件
html
AspNetPager分頁控件解決了分頁中的不少問題,直接採用該控件進行分頁處理,會將繁瑣的分頁工做變得簡單化,下面是我如何使用AspNetPager控件進行分頁處理的詳細代碼: 1.首先到
www.webdiyer.com
下載最新的AspNetPager.dll,直接在vs2005中添加引用便可。 2.在頁面上註冊控件,引入該控件,固然,須要在頁面中使用一個數據載體,我這裏使用的是repeater控件。
<%
@ Register Assembly
=
"
AspNetPager
"
Namespace
=
"
Wuqi.Webdiyer
"
TagPrefix
=
"
webdiyer
"
%>
<!--
省略
-->
<
Webdiyer:AspNetPager
id
="AspNetPager1"
runat
="server"
HorizontalAlign
="Right"
FirstPageText
="<<"
LastPageText
=">>"
PrevPageText
="<"
NextPageText
=">"
NumericButtonTextFormatString
="-{0}-"
Width
="600px"
ShowCustomInfoSection
="Left"
ShowBoxThreshold
="2"
PageSize
="5"
InputBoxClass
="text2"
TextAfterInputBox
=""
OnPageChanging
="AspNetPager1_PageChanging"
/>
3.cs代碼
DataSet ds; SqlDataAdapter dr; SqlCommand com;
protected
void
Page_Load(
object
sender, EventArgs e) {
if
(
!
IsPostBack) {
string
strconn
=
System.Configuration.ConfigurationManager.ConnectionStrings[
"
SperConnectionString1
"
].ToString(); SqlConnection con
=
new
SqlConnection(strconn); con.Open(); com
=
new
SqlCommand(); com.Connection
=
con; com.CommandText
=
"
select count(*) from Article
"
; AspNetPager1.AlwaysShow
=
true
; AspNetPager1.PageSize
=
5
; AspNetPager1.RecordCount
=
(
int
)com.ExecuteScalar(); con.Close(); RepeaterDataBind(); } }
private
void
RepeaterDataBind() {
string
strconn
=
System.Configuration.ConfigurationManager.ConnectionStrings[
"
SperConnectionString1
"
].ToString(); dr
=
new
SqlDataAdapter(
"
select * from Article
"
, strconn); ds
=
new
DataSet(); dr.Fill(ds, AspNetPager1.PageSize
*
(AspNetPager1.CurrentPageIndex
-
1
), AspNetPager1.PageSize,
"
Article
"
);
this
.Repeater2.DataSource
=
ds.Tables[
"
Article
"
];
this
.Repeater2.DataBind();
}
protected
void
AspNetPager1_PageChanging(
object
src, Wuqi.Webdiyer.PageChangingEventArgs e) { AspNetPager1.CurrentPageIndex
=
e.NewPageIndex; RepeaterDataBind(); }
protected
string
FormatString_Size_13(
string
str) {
if
(str.Length
>
33
) { str
=
str.Substring(
0
,
32
)
+
"
"
; }
return
str; }
4.最後修改AspNetPager控件的PageChanging事件爲AspNetPager1_PageChanging就能夠了。
相關文章
1.
MVC分頁控件
2.
Wpf分頁控件
3.
C# 分頁控件
4.
yii CLinkPager 分頁控件
5.
WPF裏DataGrid分頁控件
6.
WPF實現分頁控件
7.
Extjs Ext.form.ComboBox() 控件分頁
8.
wpf製做分頁控件
9.
簡單分頁控件
10.
利用AspNetpager控件分頁
更多相關文章...
•
ASP.NET HtmlAnchor 控件
-
ASP.NET 教程
•
ASP.NET HtmlButton 控件
-
ASP.NET 教程
•
Git五分鐘教程
•
算法總結-二分查找法
相關標籤/搜索
aspnetpage
控件
分頁
日期控件
Android - 控件
設置分頁
分頁功能
自定義控件
MySQL教程
SQLite教程
Spring教程
插件
文件系統
0
分享到微博
分享到微信
分享到QQ
每日一句
每一个你不满意的现在,都有一个你没有努力的曾经。
最新文章
1.
resiprocate 之repro使用
2.
Ubuntu配置Github並且新建倉庫push代碼,從已有倉庫clone代碼,並且push
3.
設計模式9——模板方法模式
4.
avue crud form組件的快速配置使用方法詳細講解
5.
python基礎B
6.
從零開始···將工程上傳到github
7.
Eclipse插件篇
8.
Oracle網絡服務 獨立監聽的配置
9.
php7 fmp模式
10.
第5章 Linux文件及目錄管理命令基礎
本站公眾號
歡迎關注本站公眾號,獲取更多信息
相關文章
1.
MVC分頁控件
2.
Wpf分頁控件
3.
C# 分頁控件
4.
yii CLinkPager 分頁控件
5.
WPF裏DataGrid分頁控件
6.
WPF實現分頁控件
7.
Extjs Ext.form.ComboBox() 控件分頁
8.
wpf製做分頁控件
9.
簡單分頁控件
10.
利用AspNetpager控件分頁
>>更多相關文章<<