❶ 如何使用AspNetPager控件
前台:
<webdiyer:AspNetPager SubmitButtonClass="buttons" ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="首页"
NextPageText="下一页" PrevPageText="前一页" LastPageText="尾页" PageSize="15" ShowInputBox="Always"
OnPageChanged="AspNetPager1_PageChanged">
</webdiyer:AspNetPager>
<!-- PageSize="15"定义每页显示数据条数 -->
后台:
/// <summary>
/// 加载事件
/// </summary>
protected void Page_Load(object sender, EventArgs e)
{
BoundList();
}
/// <summary>
/// 全局的变量,分页用的参数数据信息总数
/// </summary>
public static int sumcount;
/// <summary>
/// 绑定信息数据
/// </summary>
private void BoundList()
{
DataTable dt = GetList().Tables[0];//获取数据源
if (dt.Rows.Count > 0)
{
sumcount = dt.Rows.Count;
PagedDataSource pds = new PagedDataSource();
AspNetPager1.RecordCount = sumcount;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = dt.DefaultView;
this.gridView1.DataSource = pds; //可以绑定到Gridview 、datalist等数据控件上,此处为Gridview
this.gridView1.DataBind();
}
else
{
AspNetPager1.RecordCount = 0;
this.gridView1.DataSource = null;
gridView1.EmptyDataText = "没有相关信息!";
this.gridView1.DataBind();
}
}
/// <summary>
/// 分页控件的翻页事件
/// </summary>
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BoundList();
}
http://..com/question/334985338.html?oldq=1
❷ VB.NET中使用AspNetPager控件的详细用法
AspNetPager简单使用方法 AspNetPager作为分页工具,常常用于绑定数据控件,如DataGrid , Repeater等
在这里,简单讲解下 绑定 Repeater 控件的方法,其余控件绑定方法类似:
'全局变量 i 用于 读取 数据集记录的条数(注意:读取一次就够了)
Dim i As New Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If i = 0 Then
con = New SqlConnection(ConfigurationManager.ConnectionStrings("NEWS_ConnectionString").ConnectionString)
con.Open()
cmd = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "select count(*) from XWNRB "
'AspNetPager控件 可见
Me.AspNetPager1.Visible = True
'AspNetPager控件 每页显示大小为10条记录
Me.AspNetPager1.PageSize = 10
'AspNetPager控件 记录总的记录条数
Me.AspNetPager1.RecordCount = Convert.ToInt32(cmd.ExecuteScalar())
'AspNetPager控件 数据绑定
Me.SHOW_DATA_LIST()
i = i + 1
con.Close()
End If
End Sub
Protected Sub SHOW_DATA_LIST()
con = New SqlConnection(ConfigurationManager.ConnectionStrings("NEWS_ConnectionString").ConnectionString)
sql_Text = "select * from XWNRB where "
da = New SqlDataAdapter(sql_Text, con)
Dim ds As New Data.DataSet
'第一个参数为存储入的数据集为ds
'第二个参数为存储的起始记录序号
'第三个参数为存储的记录每页条数
'第四个参数为存储入的数据集ds中的具体某个表
da.Fill(ds, Me.AspNetPager1.PageSize * (Me.AspNetPager1.CurrentPageIndex - 1), Me.AspNetPager1.PageSize, "NEWS_LIST")
'真正绑定
Me.Repeater2.DataSource = ds.Tables("NEWS_LIST").DefaultView
Me.Repeater2.DataBind()
End Sub
'即每次点击新的页面,或者点击 Pre,Next,Last.....时候都会触发这个事件
Protected Sub AspNetPager1_PageChanged(ByVal src As Object, ByVal e As Wuqi.Webdiyer.PageChangedEventArgs) Handles AspNetPager1.PageChanged
'更新当前所在的页数序列
Me.AspNetPager1.CurrentPageIndex = e.NewPageIndex
'更新完后绑定
Me.SHOW_DATA_LIST()
End Sub
❸ 如何使用 aspnetpager ...
<webdiyer:AspNetPager ID="anpPage" runat="server" FirstPageText="第一页" LastPageText="最后一页"
NextPageText="下一页" PrevPageText="上一页" AlwaysShow="True" ShowCustomInfoSection="Right"
PageIndexBoxStyle="textinput" CssClass="MainBodyPager" PageSize="9" CustomInfoHTML="共%RecordCount%个 第%CurrentPageIndex%/%PageCount%页"
PageIndexBoxType="TextBox" ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页"
TextBeforePageIndexBox="转到" OnPageChanging="anpCampaign_PageChanging">
</webdiyer:AspNetPager>
protected void anpPage_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
anpPage.CurrentPageIndex = e.NewPageIndex;
BindData();
}
再就是注意你的存储过程了。
❹ AspNetPager怎么用
DataSet ds;
SqlDataAdapter dr;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
con.Open();
com = new SqlCommand();
com.Connection = con;
com.CommandText = "select count(*) from Employees";
AspNetPager1.AlwaysShow=true;
AspNetPager1.PageSize=15;
AspNetPager1.RecordCount = (int)com.ExecuteScalar();
con.Close();
DataListDataBind();
}
}
private void DataListDataBind()
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
dr = new SqlDataAdapter("select * from Employees", con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Employees");
DataList1.DataSource = ds.Tables["Employees"];
DataList1.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
DataListDataBind();
}
❺ AspNetPager控件的使用
AspNetPager只要你绑定好了数据,并正确设置了记录总数.它会自动根据数据隐藏/显示导航按钮的哇
❻ AspNetPager控件的具体使用方法
这是个分页的控件 只提供分页的功能。最多改变一下分页控件的样子。。
至于如何显示你的数据 要看你具体绑的是哪个控件。。
而且也只能由你自己操作改变被绑控件的属性。。进行显示,。
❼ AspNetPager如何添加和使用
<%@ Register Src="~/Manger/Bottom.ascx" TagName="Bottom" TagPrefix="uc1" %>这句是注册这个用户控件
<uc1:Bottom ID="Bottom1" runat="server" />这句是使用这个用户控件
要使用,必须先注册,至于这个用户控件有什么作用,你到~/Manger/Bottom.ascx 这个路径打开看一下用户控件的代码,就知道他是干什么用的了
❽ 如何使用 aspnetpager ...
除了样式之外(你可以再设计页面设计样式),你只需要给它提供两个值就行了第一个是AspNetPager.PageSize,它是用了指定多少条记录算一页。第二个是 AspNetPager.RecordCount,它是告诉控件总共有多少条数据。这样的话它就可以算出来需要显示多少数字导航之类的了。
❾ AspNetPager空间如何使用,绑定数据的控件用的是Repeater
首行你要引用AspNetPager.dll,然后在web.config中的system.web中加入如下代码注册AspNetPager:
<system.web>
<pages>
<controls>
<add tagPrefix="divPager" namespace="Wuqi.Webdiyer" assembly="AspNetPager"/>
</controls>
</pages>
</system.web>
然后在页面中这么用:
<divPager:AspNetPager ID="pager" OnPageChanging="pager_PageChanging" runat="server"> </divPager:AspNetPager>
其中样式自己修改,.cs中需实现protected void pager_PageChanging(object src, PageChangingEventArgs e)
就这么多了,如果还不明白可以问我