repeater中给lable赋值
HTML code
<asp:Label ID="lable_classname" runat="server"></asp:Label>
//这个lable是放在<HeaderTemplate>中的
C# code
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Label name = (Label)Repeater1.FindControl("lable_classname");
name.Text = "111";
}
当我点击一个repeater外的一个按钮时,把lable中赋值,结果赋值不上去。我调试了,后台里面直接不会执行Repeater1_ItemCommand,为什么呢?
------解决方案--------------------
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Label x = e.Item.FindControl("lable_classname") as Label ;
}
}