自已做一个Repeater就得了嘛, 写在一个类工程里面~~
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
namespace Test
{
public class MyRepeater : Repeater
{
private int displayPageSize;
public int DisplayPageSize
{
get { return displayPageSize; }
set { displayPageSize = value; }
}
int currentCount = 0;
protected override void OnItemDataBound(RepeaterItemEventArgs e)
{
base.OnItemDataBound(e);
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
currentCount++;
if (currentCount > displayPageSize)
{
e.Item.Controls.Clear();
}
}
}
}
}
页面上用的时候申请一下
<%@ Register Assembly ="Test" Namespace="Test" TagPrefix="uc1" %>
<uc1:MyRepeater runat="server" id="rpMyRepeater" DisplayPageSize="3">
<ItemTemplate>
<%# Eval("Name") %>
||
<%# Eval("Age") %>
<br />
<br />
</ItemTemplate>
</uc1:MyRepeater>
使用的时候只需要设定DisplayPageSize则只显示指定数量的记录.