zoukankan
html css js c++ java
数据的导航与跳转
protected
System.Web.UI.WebControls.DataGrid MyDataGrid;
protected
System.Web.UI.WebControls.Label lblPageCount;
protected
System.Web.UI.WebControls.Label lblCurrentIndex;
protected
System.Web.UI.WebControls.LinkButton btnFirst;
protected
System.Web.UI.WebControls.LinkButton btnPrev;
protected
System.Web.UI.WebControls.LinkButton btnNext;
protected
System.Web.UI.WebControls.LinkButton btnLast;
protected
System.Web.UI.WebControls.TextBox go;
protected
System.Web.UI.WebControls.Label Label1;
private
OleDbConnection cn
=
new
OleDbConnection();
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
btnFirst.Text
=
"
首页
"
;
btnPrev.Text
=
"
前一页
"
;
btnNext.Text
=
"
下一页
"
;
btnLast.Text
=
"
尾页
"
;
OpenDatabase();
BindGrid();
}
private
void
OpenDatabase()
{
cn.ConnectionString
=
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
"
+
Server.MapPath(
"
northwind.mdb
"
);
cn.Open();
}
private
void
ShowStats()
{
lblCurrentIndex.Text
=
"
第
"
+
(MyDataGrid.CurrentPageIndex
+
1
).ToString()
+
"
页
"
;
lblPageCount.Text
=
"
总共
"
+
MyDataGrid.PageCount.ToString()
+
"
页
"
;
}
//
btnfirst,btnprev,btnnext,btnlast的事件都要设为PagerButtonClick
public
void
PagerButtonClick(
object
sender, EventArgs e)
{
string
arg
=
((LinkButton)sender).CommandArgument.ToString();
switch
(arg)
{
case
"
next
"
:
if
(MyDataGrid.CurrentPageIndex
<
(MyDataGrid.PageCount
-
1
))
{
MyDataGrid.CurrentPageIndex
+=
1
;
}
break
;
case
"
prev
"
:
if
(MyDataGrid.CurrentPageIndex
>
0
)
{
MyDataGrid.CurrentPageIndex
-=
1
;
}
break
;
case
"
last
"
:
MyDataGrid.CurrentPageIndex
=
(MyDataGrid.PageCount
-
1
);
break
;
default
:
MyDataGrid.CurrentPageIndex
=
System.Convert.ToInt32(arg);
break
;
}
BindGrid();
ShowStats();
}
private
bool
IsNumberic(
string
oText)
{
try
{
int
var1
=
Convert.ToInt32 (oText);
return
true
;
}
catch
{
return
false
;
}
}
public
void
goClick(
object
obj,EventArgs e)
{
if
(go.Text.Trim()
!=
""
&&
this
.IsNumberic(go.Text.Trim()))
{
int
index
=
Int32.Parse(go.Text.Trim())
-
1
;
if
(index
>=
0
&&
index
<
MyDataGrid.PageCount)
{
MyDataGrid.CurrentPageIndex
=
index;
}
BindGrid();
ShowStats();
}
else
{
Response.Write(
"
<script>alert(\'跳转不能为空且必须为数字\')</script>
"
);
}
}
public
void
BindGrid()
{
OleDbConnection myConnection
=
cn;
DataSet ds
=
new
DataSet();
OleDbDataAdapter adapter
=
new
OleDbDataAdapter(
"
Select customerid,orderdate from orders order by orderid desc
"
, myConnection);
adapter.Fill(ds,
"
Document
"
);
MyDataGrid.DataSource
=
ds.Tables[
"
Document
"
].DefaultView;
MyDataGrid.DataBind();
ShowStats();
}
public
void
MyDataGrid_Page(
object
sender, DataGridPageChangedEventArgs e)
{
int
startIndex ;
startIndex
=
MyDataGrid.CurrentPageIndex
*
MyDataGrid.PageSize;
MyDataGrid.CurrentPageIndex
=
e.NewPageIndex;
BindGrid();
ShowStats();
}
查看全文
相关阅读:
全美在线上云 保证上千考场统一监考
如何构建一个较为通用的业务技术架构
在tomcat下context.xml中配置各种数据库连接池
Java中的多线程
彻底理解ThreadLocal
plsql工具使用
软件清单
EL表达式
AOP(execution表达式)
JSTL标签库之核心标签
原文地址:https://www.cnblogs.com/ahuang1118/p/172571.html
最新文章
Luogu P1231 教辅的组成
EZ 2018 03 23 NOIP2018 模拟赛(五)
Luogu T24242 购物券Ⅰ(数据已加强)
EZ 2018 03 16 NOIP2018 模拟赛(四)
Image Processing and Analysis_15_Image Registration:HAIRIS: A Method for Automatic Image Registration Through Histogram-Based Image Segmentation——2011
Image Processing and Analysis_15_Image Registration:Mutual-Information-Based Registration of Medical Survey——2003
Image Processing and Analysis_15_Image Registration:Image registration methods a survey——2003
硕士研究生该如何开题?
Computer Vision_18_Image Stitching:A survey on image mosaicing techniques——2013
Image Processing and Analysis_15_Image Registration:A survey of medical image registration——1998
热门文章
Image Processing and Analysis_15_Image Registration:Multi-modal volume registration by maximization of mutual information——1996
Image Processing and Analysis_15_Image Registration:a survey of image registration techniques——1992
云服务器ECS共享标准型S6全新发布,行业内最具性价比
企业要复工 阿里云来帮忙
MaxCompute项目子账号做超级管理员
无缝衔接 gRPC 与 dubbo-go
在家运维不用慌 | 盘点那些远程运维中的云上利器
阿里巴巴专家教你如何在家安全高效开发软件
稳定性专题 | 通过链路追踪快速发现和定位业务问题的实践
IOT设备连接上云
Copyright © 2011-2022 走看看