分页控件

Imports System.Data.SqlClient
Imports System.Data
Partial Class News_more
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Call BindData()

        End If

    End Sub

    Private Sub ChangePage(ByVal src As Object, ByVal e As Wuqi.Webdiyer.PageChangedEventArgs)
        AspNetPager.CurrentPageIndex 
=  e.NewPageIndex
        BindData()
    End Sub
    Private Sub BindData()
      
        Dim strconn As String 
=  System.Configuration.ConfigurationManager.ConnectionStrings( " Ccopconnstr " ).ToString()
        Dim objconn As SqlConnection 
=  New SqlConnection(strconn)
        objconn.Open()
        Dim sql As String 
=   " SELECT count(*) FROM News "
        Dim cmd As SqlCommand 
=  New SqlCommand(sql, objconn)
        
'  cmd.Parameters.Add(New SqlParameter("@ispass", SqlDbType.Bit))
         '  cmd.Parameters("@ispass").Value = True
        Dim i As Integer  =  CType(cmd.ExecuteScalar, Integer)
        AspNetPager.RecordCount 
=  i
        sql 
=   " SELECT  id,title,datetime FROM News "
        cmd 
=  New SqlCommand(sql, objconn)
        Dim adp As SqlDataAdapter 
=  New SqlDataAdapter(cmd)
        Dim ds As DataSet 
=  New DataSet
        adp.Fill(ds, AspNetPager.PageSize 
*  (AspNetPager.CurrentPageIndex  -   1 ), AspNetPager.PageSize,  " SongDate " )
        DataList1.DataSource 
=  ds.Tables( " SongDate " )
        If ds.Tables(
" SongDate " ).Rows.Count  >   0  Then
            DataList1.DataBind()
        End If
        AspNetPager.CustomInfoText 
=   " 记录总数:<font color='blue'><b> "   +  AspNetPager.RecordCount.ToString  +   " </b></font> "
        AspNetPager.CustomInfoText 
+=   "  总页数:<font color='blue'><b> "   +  AspNetPager.PageCount.ToString  +   " </b></font> "
        AspNetPager.CustomInfoText 
+=   "  当前页:<font color='red'><b> "   +  AspNetPager.CurrentPageIndex.ToString  +   " </b></font> "
    End Sub
End Class
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值