AspNETPager的用法

AspNETPager的用法nbsp 先下载 4 3 版 然后安装问题 1 在 vs net2005 中 该控件并不能自动添加到工具面板中 需要手动添加项 选定 AspNetPager dll 即可 2 在 codeBehind 的 cs 文件中 要 usingWuqi Webdiyer 3 写好 ChangePage 事件后 要与 aspnetpager 控件相关联以下是一段示例代码 前台 default aspx nbsp

 先下载4.3版,然后安装

问题:

1.在vs.net2005中,该控件并不能自动添加到工具面板中,需要手动添加项,选定AspNetPager.dll,即可

2.在codeBehind的cs文件中,要using Wuqi.Webdiyer;

3.写好ChangePage事件后,要与aspnetpager控件相关联

以下是一段示例代码:

前台default.aspx


AspNETPager的用法AspNETPager的用法 <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=test_Default StylesheetTheme=default %>

AspNETPager的用法AspNETPager的用法

<%@ Register Assembly=AspNetPager Namespace=Wuqi.Webdiyer TagPrefix=webdiyer %>

AspNETPager的用法

<html xmlns=”http://www.w3.org/1999/xhtml” >

AspNETPager的用法

<head runat=”server”>

AspNETPager的用法    

<title>无标题页
title>


AspNETPager的用法


head>


AspNETPager的用法

<body>

AspNETPager的用法    

<form id=”form1″ runat=”server”>

AspNETPager的用法    

<div>

AspNETPager的用法        

<asp:DataList ID=”DataList1″ runat=”server”>

AspNETPager的用法            

<ItemTemplate>

AspNETPager的用法                ProductName:
AspNETPager的用法                


<asp:Label ID=”ProductNameLabel” runat=”server” Text=’<%# Eval(“ProductName”) %>
‘>
AspNETPager的用法                

asp:Label><br />


AspNETPager的用法                

<br />

AspNETPager的用法            


ItemTemplate>


AspNETPager的用法        


asp:DataList>


AspNETPager的用法        

<webdiyer:aspnetpager id=”pager1″ runat=”server” onpagechanged=”ChangePage”>
webdiyer:aspnetpager>

    
AspNETPager的用法    

div>


AspNETPager的用法    


form>


AspNETPager的用法


body>


AspNETPager的用法


html>

 

后置代码:default.aspx.cs

 

AspNETPager的用法using
 System;
AspNETPager的用法
using

 System.Data;
AspNETPager的用法
using

 System.Configuration;
AspNETPager的用法
using

 System.Collections;
AspNETPager的用法
using

 System.Web;
AspNETPager的用法
using

 System.Web.Security;
AspNETPager的用法
using

 System.Web.UI;
AspNETPager的用法
using

 System.Web.UI.WebControls;
AspNETPager的用法
using

 System.Web.UI.WebControls.WebParts;
AspNETPager的用法
using

 System.Web.UI.HtmlControls;
AspNETPager的用法
using

 cpp114.tools.oledb;
AspNETPager的用法
using

 System.Data.OleDb;
AspNETPager的用法
using

 Wuqi.Webdiyer;
AspNETPager的用法
AspNETPager的用法

public partial class

 test_Default : System.Web.UI.Page
AspNETPager的用法AspNETPager的用法

{

AspNETPager的用法    
protected OleDbConnection conn = new
 OleDbConnection();
AspNETPager的用法    
protected OleDbCommand cmd = new
 OleDbCommand();
AspNETPager的用法
AspNETPager的用法    

protected void Page_Load(object
 sender, EventArgs e)
AspNETPager的用法AspNETPager的用法    
{

AspNETPager的用法AspNETPager的用法        
if (!IsPostBack) 
{

AspNETPager的用法            initdb();
AspNETPager的用法            conn.Open();
AspNETPager的用法            cmd.CommandText 


= select count(*) from t_product
;
AspNETPager的用法            pager1.RecordCount 
= (int
)cmd.ExecuteScalar();
AspNETPager的用法            conn.Close();
AspNETPager的用法            BindData();
AspNETPager的用法                       
AspNETPager的用法        }




AspNETPager的用法
AspNETPager的用法    }


AspNETPager的用法 
AspNETPager的用法 

//初始化连接对象
AspNETPager的用法AspNETPager的用法
    protected void initdb(){

AspNETPager的用法        conn.ConnectionString 
= oledbtool.myConnStr +
 Server.MapPath(oledbtool.mydbName);
AspNETPager的用法        cmd.Connection 
=
 conn;        
AspNETPager的用法    }

AspNETPager的用法
AspNETPager的用法 

//数据绑定
AspNETPager的用法AspNETPager的用法
    protected void BindData() {

AspNETPager的用法        initdb();
AspNETPager的用法        OleDbDataAdapter sda 

= new OleDbDataAdapter(select * from t_product
,conn);       
AspNETPager的用法        DataSet ds 
= new
 DataSet();
AspNETPager的用法        
//sda.Fill(ds, 10, 10, “temptbl”);

AspNETPager的用法
        sda.Fill(ds, pager1.PageSize * (pager1.CurrentPageIndex  1), pager1.PageSize, temptbl);
AspNETPager的用法        DataList1.DataSource 
= ds.Tables[temptbl
];
AspNETPager的用法        DataList1.DataBind();
AspNETPager的用法    }


AspNETPager的用法
AspNETPager的用法 

//翻页事件
AspNETPager的用法
    protected void ChangePage(object src, PageChangedEventArgs e)
AspNETPager的用法AspNETPager的用法    
{

AspNETPager的用法        pager1.CurrentPageIndex 
=
 e.NewPageIndex;
AspNETPager的用法        BindData();
AspNETPager的用法    }

    
AspNETPager的用法
AspNETPager的用法}



AspNETPager的用法
AspNETPager的用法

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227450.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午9:17
下一篇 2026年3月16日 下午9:17


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号