在具有父面板的子面板中查找控件 [英] Find controls in child Panel which has parent Panel
本文介绍了在具有父面板的子面板中查找控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有父面板控件,其中包括CheckBoxes.
如果我选中其中一个ChechBox,则会打开另一个子面板,并且其中还包括chechboxes.
我的要求是我必须使用FindControl查找子复选框
我该怎么办.
请任何人帮助我.
谢谢
I have parent Panel control which include CheckBoxes.
If I check one of them ChechBox another child Panel opens and it also include chechboxes.
My requirement is I have to find child checkboxes using FindControl
How can I do this.
Please anyone Help Me.
Thanks
推荐答案
您是否正在寻找这个
Are you looking for this
CheckBox chk1= this.FindControl("parentPanel").FindControl("childPanle").FindControl("checkBox1") as CheckBox;
childpanel.findcontrol("checkbox in child panel");
试试这个-
Hi,
Try this-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:panel id="Panel1" runat="server" xmlns:asp="#unknown">
<asp:checkbox id="CheckBox1" runat="server" checked="true" />
<asp:panel id="Panel2" runat="server">
<asp:checkbox id="CheckBox2" runat="server" />
<asp:checkbox id="CheckBox3" runat="server" />
</asp:panel>
</asp:panel>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (((CheckBox)Panel1.FindControl("CheckBox1")).Checked)
{
foreach (Control ctrl in ((Panel)Panel1.FindControl("Panel2")).Controls)
{
if (ctrl.GetType() == typeof(CheckBox))
{
//your checkbox
}
}
}
}
这篇关于在具有父面板的子面板中查找控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文