频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

datalist 分页的用户控件,我公司sunYun原创,如需转载,请联系作者

来源: 作者: 出处:巧巧读书 2006-10-11 进入讨论组
QQRead:http://www.qqread.com/dotnet/w224310.html

  listControl.ASPx
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="listControl.ascx.vb" Inherits="govoa.listControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
共有<ASP:Label id="lblRecordCount" ForeColor="red" runat="server" />条记录  当前为<ASP:Label id="lblCurrentPage" ForeColor="red" runat="server" />/<ASP:Label id="lblPageCount" ForeColor="red" runat="server" />页
<ASP:LinkButton id="lblPrevious" runat="server" text=""></ASP:LinkButton> 
<ASP:DropDownList id="NumPerPage" runat="server" AutoPostBack="True">
    <ASP:ListItem Value="5">
        5行/页</ASP:ListItem>
    <ASP:ListItem Value="8" Selected="True">
        8行/页</ASP:ListItem>
    <ASP:ListItem Value="10">
        10行/页</ASP:ListItem>
    <ASP:ListItem Value="15">
        15行/页</ASP:ListItem>
    <ASP:ListItem Value="20">
        20行/页</ASP:ListItem>
    <ASP:ListItem Value="25">
        25行/页</ASP:ListItem>
    <ASP:ListItem Value="30">
        30行/页</ASP:ListItem>
    <ASP:ListItem Value="35">
        35行/页</ASP:ListItem>
    <ASP:ListItem Value="40">
        40行/页</ASP:ListItem>
</ASP:DropDownList>
<ASP:TextBox ID="txtPage" Runat="server" Width="30"></ASP:TextBox><ASP:Button ID="btnGo" Runat="server" Text="转到"></ASP:Button>



listControl.ASPx.vb

Imports System.Data.SqlClient
Public MustInherit Class listControl
    Inherits System.Web.UI.UserControl
    Protected WithEvents lblRecordCount As System.Web.UI.WebControls.Label
    Protected WithEvents lblCurrentPage As System.Web.UI.WebControls.Label
    Protected WithEvents lblPageCount As System.Web.UI.WebControls.Label
    Protected WithEvents lblPrevious As System.Web.UI.WebControls.LinkButton
    Protected WithEvents lblNext As System.Web.UI.WebControls.LinkButton
    Protected WithEvents NumPerPage As System.Web.UI.WebControls.DropDownList
    Protected WithEvents txtPage As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnGo As System.Web.UI.WebControls.Button
    Private m_DataContainer As Repeater
    Private m_datasource As String
    Private m_toRefresh As Boolean = False

    Private MyConn As SqlConnection
    Private RecordCount, PageCount, CurrentPage As Integer


    '/ <summary>
    '/ 取得需要绑定的控件
    '/ </summary>

    Public Property GetRelatedControl() As Repeater
        Get
            Return m_DataContainer
        End Get
        Set(ByVal Value As Repeater)
            m_DataContainer = Value
        End Set
    End Property

    Public Property ToRefresh() As Boolean
        Get
            Return m_toRefresh
        End Get
        Set(ByVal Value As Boolean)
            m_toRefresh = Value
        End Set
    End Property

    Public Property GetRelatedSqlStr() As String
        Get
            Return m_datasource
        End Get
        Set(ByVal Value As String)
            m_datasource = Value
            If m_toRefresh Then
                refreshData()
            End If
        End Set
    End Property


#Region " Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        MyConn = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
        MyConn.Open()
        ViewState("PageSize") = NumPerPage.SelectedItem.Value.ToString()
        If Not Page.IsPostBack Then
            BindControl()
            CurrentPage = 0
            ViewState("PageIndex") = 0

            '计算总共有多少记录
           &进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章