You need to enumerate through companyRepeater.Items using a foreach block as below
foreach (RepeaterItem ri in companyRepeater.Items)
{
CheckBox chkbox_All = ri.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...");
}
}
}
EDIT
If you want to display the ID of the checked checkboxes, add a Literal somewhere outside the repeater
<asp:Literal ID="ltChecked" runat="server" />
and add the id to ltChecked.Text if the checkbox is checked
foreach (RepeaterItem ri in companyRepeater.Items)
{
CheckBox chkbox_All = ri.FindControl("foo") as CheckBox;
if (chkbox_All != null)
{
if (chkbox_All.Checked)
{
ltChecked.Text += chkbox_All.ClientID;
ltChecked.Text += ", ";
}
}
}
EDIT 2
To prevent the page reload when checking the checkbox, remove AutoPostBack="True" from the foo checkbox
<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" name="foo" /></td>
</tr>
EDIT 3
To get the compnName1 value from the same row as the checked checkbox, add a hidden field (hdCompName) that holds the compnName1 value in the 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" name="foo" />
<asp:HiddenField id="hdCompName" runat="server" Value='<%# Eval("compnName1") %>' />
</td>
</tr>
then get the value of hdCompName in the code behind as below
foreach (RepeaterItem ri in companyRepeater.Items)
{
CheckBox chkbox_All = ri.FindControl("foo") as CheckBox;
if (chkbox_All != null)
{
if (chkbox_All.Checked)
{
HiddenField hdCompName = ri.FindControl("hdCompName") as HiddenField;
ltChecked.Text += hdCompName.Value;
ltChecked.Text += ", ";
}
}
}