views:

238

answers:

3

I am making use of a ASP.NET Repeater.

My Repeater is called myRepeater and I only want to display 20 items per page.

Can this be done with a ASP.NET Repeater and if so what changes must i make to my code below? I want to be able to make use of paging.......... C# example is also fine!!

 ' 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()

Thanks in advance!!

+1  A: 

I have a post about that in my blog: http://ozsenegal.wordpress.com/2009/08/16/custom-page-asp-net-com-repeater-e-data-list/

Use google translator.

google translated.. very nice.
jinsungy
+1  A: 

This article might help you out. You're going to have to create the paging logic yourself. I would suggest for the paging controls, you just have a "previous" and a "next" and you enable/disable those based on whether or not those actions are valid based on "where" you are in the paged data set.

Brandon Montgomery
A: 

Here are a few guides to get you started:

http://www.developer.com/article.php/3646011

http://aspalliance.com/157_Paging_in_DataList

http://www.codeproject.com/KB/webforms/Aspnet_Repeater_Control.aspx

You should be able to copy and paste this code into your project, and just change a couple of things to match your project.

Albert