只能在Repeater的ItemDataBound事件中,用FindControl方法获取,然后重新绑定,在其它地方用FindControl方法不行的。比如在事件中可以这样写
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Button btn = (Button)e.Item.FindControl("btnDetail");
int i = Convert.ToInt32(btn.CommandArgument.ToString());
List
listBody = bllNews.historyMessagesByNewsID(i);
Repeater rep = (Repeater)e.Item.FindControl("Repeaters");
rep.DataSource = listBody;
rep.DataBind();
}
在ItemDataBound事件里用
(控件类型)e.Item.FindControl("控件ID")函数查找Repeater中的控件!