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