怎么控制repeate中一行显示的个数

2025-01-01 01:48:29
推荐回答(3个)
回答1:

每5行折行
.aspx


<%# Eval("Name") %>
" : string.Empty %>' >



.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 = new 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; }
}

回答2:

有几个列,就有几列。也就是每行显示的个数

回答3:

如果想控制一行显示多个,可以用DataList控件,Repeate控件只能用于每行显示一个,但是可以通过css来控制每行显示的个数
如果有什么不懂可以hi~我,给你写个例子