I have checkboxes created in repeater:
<asp:Repeater ID="companyRepeater" runat="server" >
<ItemTemplate>
<tr class = "DGItemStyle" id="myresultsRow1" runat="server" style='<%# SetBoxVisibilityReverse(Eval("compnName1").ToString()) %>'>
<td style="padding:0.5em;"><%#Eval("compnAddress1") %></td>
.....
<td><asp:CheckBox id="foo" runat="server" AutoPostBack="True" name="foo" /></td>
</tr>
I want to find out which checkbox is currently selected by user, so in the codebehind I do:
CheckBox chkbox_All = FindControl("foo") as CheckBox;
if (chkbox_All != null)
{
if (!chkbox_All.Checked)
{
Response.Write("No checked");
}
else
{
var IDs = chkbox_All.ClientID;
Response.Write("ID here...");
}
}
But what I found is that the chkbox_All
is always null no matter how many checkboxes are selected. Why is it so and how could I find which checkbox is checked in this case ?
Aucun commentaire:
Enregistrer un commentaire