软件发布

热门搜索HoneyView 酷笑8超级文字转MP3工具 橘子游戏多窗口同步器 卡布西游小窗口工具

手机版,更便捷!

下载排行榜首页软件下载安卓下载资讯教程推荐专题装机必备
当前位置:文章资讯 > 编程开发 >

repeater控件分页功能代码怎么弄?ASP.NET中教你轻松搞定。

时间:2016-12-20 浏览次数: 编辑:9upk

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim objConn As OleDbConnection = New OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data\myweb.mdb") & ";Persist Security Info=False")
Dim strsql As String = "SELECT [wz_id],[wz_bt],[wz_hit],[wz_zz],mid(wz_nr,1,200) as sub_wz FROM [wenzhang] ORDER BY [wz_id] DESC"

Dim objCommand As OleDbDataAdapter = New OleDbDataAdapter(strsql, objConn)
Dim ds As DataSet = New DataSet()
Dim CurPage As Integer

objCommand.Fill(ds)

'对PagedDataSource 对象的相关属性赋值
Dim objPds As PagedDataSource = New PagedDataSource()
objPds.DataSource = ds.Tables(0).DefaultView
objPds.AllowPaging = True
objPds.PageSize = 10


'当前页面从Page查询参数获取
If (Request.QueryString("Page") <> "") Then
CurPage = Convert.ToInt32(Request.QueryString("Page"))
Else
CurPage = 1
End If
objPds.CurrentPageIndex = CurPage - 1
lblCurrentPage.Text = "当前为第: " & CurPage.ToString() & "页"
lblcount.Text = "共有" & objPds.PageCount & "页"
If objPds.IsFirstPage = False Then
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage - 1)

lnkfirst.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & "1"
End If
If objPds.IsLastPage = False Then
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage + 1)

lnklast.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(objPds.PageCount)
End If

'把PagedDataSource 对象赋给Repeater控件
Repeater1.DataSource = objPds 'repeater的数据源就是这
Repeater1.DataBind()

End Sub

'其中lnknext、lnkprev、lnkfirst、lnklast是HyperLink控件,lblcurrentpage、lblcout是label控件
 

标签: repeater

上一篇:单元测试需要什么样的代码覆盖率?代码下一篇:AgileEAS.NET平台开发业务数据报表处理

相关文章

最新评论

本类排行榜

图文专题

  • 汽车保养软件
  • 360安全卫士
  • 手机软件专题合集
  • 输入法绿色版