载入中
自定义HTML载入中... loading
.Net分页控件AspNetPager.dll [转贴 2008-07-23 15:58:49]  删除... 
字体变小 字体变大
1.添加引用
2.aspx文件加入
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
3.aspx文件加入
<asp:DataGrid ID="VideoAdmin" runat="server">
</asp:DataGrid>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="15" style="font-size:14px;" HorizontalAlign="Right" NumericButtonCount="6" NumericButtonTextFormatString="[{0}]" CustomInfoHTML="第 <font color='red'><b>%CurrentPageIndex%</b></font> 页 共 %PageCount% 页 显示 %StartRecordIndex%-%EndRecordIndex% 条" InputBoxStyle="width:24px; height:14px;" ShowInputBox="Always" SubmitButtonText=" GO " FirstPageText="[首 页]" PrevPageText="[上 页]" NextPageText="[下 页]" LastPageText="[末 页]" TextBeforeInputBox="转到第" TextAfterInputBox="页 " PagingButtonSpacing="10px" width="100%" ShowCustomInfoSection="Left" UrlPaging="true" OnPageChanging="AspNetPager1_PageChanging"></webdiyer:AspNetPager>
具体参数根据需求自定
4.cs文件引入命名空间
using Wuqi.Webdiyer;
6.初始化数据绑定
if (!IsPostBack)
{
string SqlStr = "select count(*) from *";
AspNetPager1.RecordCount = SqlHelper1.selcount(SqlStr); //查询记录总数赋值给AspNetPager1
//SqlHelper1.selcount是自定义操作数据库方法
DataGridDataBind(); //数据绑定DataGrid
}
7.数据绑定方法--自定义分页
private void DataGridDataBind()
{
string SqlStr = "select * from *";
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["connectionStrings"]);
//创建数据适配器对象
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
//创建DataSet对象
DataSet ds = new DataSet();
try
{
//从指定的索引开始取PageSize条记录
da.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "CurDataTable");
//填充数据集
da.Fill(ds, "AllDataTable");
//设置DataGrid控件实际要显示的项数
VideoAdmin.VirtualItemCount = ds.Tables["AllDataTable"].Rows.Count;
//进行数据绑定
VideoAdmin.DataSource = ds.Tables["CurDataTable"];
VideoAdmin.DataBind();
}
catch(Exception error)
{
Response.Write(error.ToString());
}
}
8.分页控件事件
protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
DataGridDataBind();
}
AspNetPager.dll下载

如要制作无刷新分页
magicajax.dll下载
1.添加引用
2.配置webconfig
<system.web>
<httpModules>
<add name="MagicAjaxModule" type="MagicAjax.MagicAjaxModule, MagicAjax"/>
</httpModules>
</system.web>
3.aspx页面加入<%@ Register Assembly="MagicAjax" Namespace="MagicAjax.UI.Controls" TagPrefix="ajax" %>
4.aspx页面加入
<ajax:AjaxPanel id="AjaxPanel1" runat="server">
<asp:DataGrid ID="VideoAdmin" runat="server">
</asp:DataGrid>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server">
</webdiyer:AspNetPager>
</ajax:AjaxPanel>
票数:
什么是“我顶”?
点击数:    评论数:
本文章引用通告地址(TrackBack Ping URL)为:
本文章尚未被引用。
发表评论
大 名:
(不填写则显示为匿名者)
网 址:
(您的网址,可以不填)
标 题:
内 容:
请根据下图中的字符输入验证码:
(您的评论将有可能审核后才能发表)
和讯个人门户 v1.0 | 和讯部落 | 客服中心