我正在尝试更改按钮的可见性和Repeater控件中的2个标签,但visual studio找不到它们。我在按钮的点击事件中使用此代码。
protected void BtnCompacta_Click(object sender, EventArgs e)
{ this.modoVisualiza = "Compacta";
foreach (RepeaterItem item in RNoticies.Items)
{
Label lbTexto = (Label)item.FindControl("LbTexto");
Label lbSubtitulo = (Label)item.FindControl("LbSubtitulo");
HyperLink hlVermas = (HyperLink)item.FindControl("HLvermas");
lbTexto.Visible = false;
lbSubtitulo.Visible = false;
hlVermas.Visible = true;
BtnDetalle.CssClass = "btnNoticies";
BtnCompacta.CssClass = "btnNoticiesActive";
}
RNoticies.DataBind();
}
事件可以看到变量,并且在转发器外部更改按钮的类,但不会更改转发器的控件可见性。你能帮帮我吗?