西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁編程開發(fā)ASP.NET → ASP.NET中教你實現(xiàn)repeater控件分頁功能代碼實現(xiàn)

ASP.NET中教你實現(xiàn)repeater控件分頁功能代碼實現(xiàn)

相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2010/9/15 9:31:24字體大小:A-A+

作者:佚名點擊:384次評論:0次標簽: 控件分頁功能 repeater

  • 類型:外語學(xué)習(xí)大。5.6M語言:中文 評分:8.0
  • 標簽:
立即下載

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 對象的相關(guān)屬性賦值
Dim objPds As PagedDataSource = New PagedDataSource()
objPds.DataSource = ds.Tables(0).DefaultView
objPds.AllowPaging = True
objPds.PageSize = 10


'當(dāng)前頁面從Page查詢參數(shù)獲取
If (Request.QueryString("Page") <> "") Then
CurPage = Convert.ToInt32(Request.QueryString("Page"))
Else
CurPage = 1
End If
objPds.CurrentPageIndex = CurPage - 1
lblCurrentPage.Text = "當(dāng)前為第: " & 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的數(shù)據(jù)源就是這
Repeater1.DataBind()

End Sub

'其中l(wèi)nknext、lnkprev、lnkfirst、lnklast是HyperLink控件,lblcurrentpage、lblcout是label控件
 

    相關(guān)評論

    閱讀本文后您有什么感想? 已有人給出評價!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評論

    最新評論

    發(fā)表評論 查看所有評論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)