How to retrieve all checkboxes

2

In the code below, I have tried to retrieve all the checkboxes but I can not bring anything, I would not like to put ID, but retrieve countless selected checkboxes, what can I do? I just put 2 as an example: ( Code Behind )

<div class="form-group">                  
    <label for="teste" class="col-sm-2 control-label">teste</label>               
    <div class="col-xs-11 col-sm-6">     
        <asp:TextBox ID="teste" class="form-control" runat="server"></asp:TextBox>
    </div> 
    <div class="col-xs-1 col-sm-1">
        <asp:CheckBox ID="CheckMed" runat="server" />
    </div>        
    <div class="col-xs-1 col-sm-1">
        <asp:CheckBox ID="CheckSun" runat="server" />
    </div>
</div>        

    
asked by anonymous 22.05.2017 / 20:25

1 answer

2

I think it's not the best way, but you can find it this way:

CheckBox chkCheckMed= (CheckBox)PanelBar.FindControl("CheckMed");

PanelBar is just an example. You should place your items inside a Panel of your choice to function as in this example. Note that using this way induces various errors. If for some reason the item ID is changed, for example, it will no longer find the object.

Remember that to use checkbox , you need to call UI.WebControls :

using System.Web.UI.WebControls;
    
23.05.2017 / 17:56