[英]Paging with an ASP.NET Repeater?
我正在使用ASP.NET转发器。
我的中继器称为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()
提前致谢!!
本文可能会帮助您。 您将必须自己创建分页逻辑。 对于分页控件,我建议您只有一个“上一个”和“下一个”,然后根据您在分页数据集中的“位置”,根据这些动作是否有效来启用/禁用它们。
我在博客中发布了有关此内容的帖子: http : //ozsenegal.wordpress.com/2009/08/16/custom-page-asp-net-com-repeater-e-data-list/
使用谷歌翻译。
以下是一些入门指南:
http://www.developer.com/article.php/3646011
http://aspalliance.com/157_Paging_in_DataList
http://www.codeproject.com/KB/webforms/Aspnet_Repeater_Control.aspx
您应该能够将此代码复制并粘贴到您的项目中,并且只需更改几件事即可匹配您的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.