Thursday, 19 September 2013

Find All Radio Buttons in ASP Table

Find All Radio Buttons in ASP Table

I have an ASP table which contains a large number of radio buttons. I want
to loop through them all quickly and set the checked property to false:
<asp:Table runat=Server ID=tblSchedule>
<asp:TableRow>
<asp:TableCell>
<asp:RadioButton runat=Server ID=rdb1/>
</asp:TableCell>
</asp:TableRow>
</asp:table>
The following code never returns any results though.
foreach (RadioButton rdb in tblSchedule.Controls.OfType<RadioButton>())
{
rdb.Checked = false;
}

No comments:

Post a Comment