ASP.NET中 “Datalist“ 内我放个TextBox控件 我怎么控制TextBox的隐藏和显示?
在DataList中有个TextBox和Button1,我想点击Button1就显示TextBox?
<asp:DataList ID="DataList1" runat="server" Height="47px" >
<ItemTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="评论" style="height: 21px" />
<asp:TextBox ID="TB_wenbei" runat="server" Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:DataList>
要在这个Button1的单击事件里显示要怎么写代码?
protected void Button1_Click(object sender, EventArgs e)
{
}
------解决方案--------------------C# code
protected void Button1_Click(object sender, EventArgs e)
{
Button button = sender as Button;
if (button == null)
return;
Control textbox = button.Parent.FindControl("TB_wenbei");
if(textbox != null)
textbox.Visible = false;
}
------解决方案--------------------
4楼写的是隐藏了,lz自己改下就行了。
------解决方案--------------------