昊仔

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

我知道的两种方法,其实都一样!

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;
}
}

posted on 2013-06-03 21:05  昊仔  阅读(396)  评论(0编辑  收藏  举报