每5行折行
.aspx
<%# Eval("Name") %>
.aspx.cs
public partial class RepeaterLine : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
List
list.Add(new User { Id = 1, Name = "aa" });
list.Add(new User { Id = 2, Name = "bb" });
list.Add(new User { Id = 3, Name = "cc" });
list.Add(new User { Id = 4, Name = "dd" });
list.Add(new User { Id = 5, Name = "ee" });
list.Add(new User { Id = 6, Name = "ff" });
Repeater1.DataSource = list;
Repeater1.DataBind();
}
}
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
有几个
如果想控制一行显示多个,可以用DataList控件,Repeate控件只能用于每行显示一个,但是可以通过css来控制每行显示的个数
如果有什么不懂可以hi~我,给你写个例子