我知道的两种方法,其实都一样!
1、
public partial class repeater获取控件 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("get"))
{
Button button = Repeater1.Controls[Repeater1.Controls.Count-1].FindControl("Button2") as Button;//关键在于Controls[Repeater1.Controls.Count-1]
string s = button.CommandName;
}
}
}
2、
foreach (RepeaterItem item in Repeater1.Controls)
{
if (item.ItemType == ListItemType.Footer)
{
item.FindControl("lb_index").Visible = true;
break;
}
}