2010-02-05 41 views
1

我正在使用ASP.NET Repeater。使用ASP.NET Repeater分頁?

我的中繼器被稱爲myRepeater,我只想每頁顯示20個項目。

這可以使用ASP.NET Repeater完成,如果有的話,我必須對我的代碼做些什麼改變?我希望能夠使用分頁.......... C#的例子也很好!

' Define data objects 
    Dim conn As SqlConnection 
    Dim Comm As SqlCommand 
    Dim reader As SqlDataReader 

    conn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) 

    Comm = New SqlCommand(_ 
    ("Select * from TableName"), conn) 

    ' Open the connection 
    conn.Open() 

    ' Execute the category command 
    reader = Comm.ExecuteReader() 

    ' Bind the reader to the repeater.......... 
    myRepeater.DataSource = reader 
    myRepeater.DataBind() 

    ' Close the reader 
    reader.Close() 
    ' Close the connection 
    conn.Close() 

在此先感謝!

+0

Google提供的解決方案不能幫助您嗎? http://www.google.com/search?q=repeater+paging –

+0

或者就此而言,SO上的任何類似問題? http://stackoverflow.com/search?q=repeater+paging –

+0

不是非常有幫助,他們都非常複雜! – Etienne

回答

5

This article可能會幫助你。你將不得不自己創建分頁邏輯。我建議對於分頁控件,你只需要一個「前一個」和一個「下一個」,然後根據你在分頁數據集中的「哪裏」,這些動作是否有效來啓用/禁用這些控件。