hey guys i have these code in my web:
<asp:Panel ID="Panel1" runat="server"><table>
<tr>
<td>
<asp:RadioButton ID="rdbParametroExterno" Text="[P] Parametro Externo" runat="server"
Enabled="False" /><br />
<asp:RadioButton ID="rdbDatoGeneral" Text="[G] Dato General" runat="server" Enabled="False" /><br />
<asp:RadioButton ID="rdbFormula" Text="[F] Formula" runat="server" Enabled="False" /><br />
<asp:RadioButton ID="rdbFormulaAcumulable" Text="[A] Formula Acumulable" runat="server"
Enabled="False" /><br />
<asp:RadioButton ID="rdbDatoFijo" Text="[D] Dato Fijo" runat="server" Enabled="False" /><br />
<asp:RadioButton ID="rdbDatoVariable" Text="[V] Dato Variable" runat="server" Enabled="False" /><br />
<asp:RadioButton ID="rdbFuncionInterna" Text="[I] Funcion Interna" runat="server"
Enabled="False" /><br />
<asp:RadioButton ID="rdbTablaSistema" Text="[T] Tabla del Sistema" runat="server"
Enabled="False" /><br />
</td>
</tr>
</table></Panel>
i need to loop through all of them, so i can enable them to true when i click a button, i was trying with a foreach, but it doesnt seem to work, if you could help me that’d be cool, thank you!
protected void btnNew_Click(object sender, ImageClickEventArgs e)
{
foreach (Control c in Panel1.Controls)
{
if (c is RadioButton)
{
if (((RadioButton)c).Enabled == false)
{
((RadioButton)c).Enabled = true;
}
}
}
}
i’d really appreciate your help!
I’m assuming your storing all the radio buttons and button inside a form, which is also inside the Panel. Unfortunately there are more sub controls inside the panel than just the radio buttons. Try something like this:
ASP.NET
C#
This will iterate through all the controls until it finds the radio button sub controls and enables them. 🙂