capturing checkbox.checked in repeater control

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I have a problem capturing the checkboxes that are checked, I get false
irrespective of wether they are checked or not.

I have gone thru the sample code on this forum, but they dun seem to work.
This is the code that I used to go thru the repeater control to find my
checkboxes.

foreach(RepeaterItem r in MyRepeater.Items)
{
for (int i=1; i<=6; i++) //6 checkboxes
{
CheckBox chk = (CheckBox)r.FindControl("chkbox"+ i);
if(chk.Checked)
{
tstdAnswer += "1";
}
else
tstdAnswer += "0";
}
}
lbl2.Text += " tstdAnswer is: " + tstdAnswer;

I used the step-by-step debugger, n everytime, the program will loop
straight to the false code, n give me a "000000" string each time.

I databind the checkbox in the html code as below, display of the info is
perfectly correct, so the error shouldn't be here. Below is a cut-down
version of my code:

<ASP:REPEATER id="MyRepeater" runat="server">
<ItemTemplate>
<asp:CheckBox id="chkbox1" runat="server" Checked="false" visible='<%#
DataBinder.Eval(Container.DataItem, "choiceA").ToString() != "" %>' >
</asp:CheckBox>
</ItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</ASP:REPEATER>

TIA.
Andrew.

.



Relevant Pages

  • RE: Prompt user to select a printer using a checkbox within a user
    ... Below is working sample code to display userform containing 2 checkboxes ... Private Sub CheckBox1_Click ... Dim allOff As Boolean ...
    (microsoft.public.excel.programming)
  • Re: "Check All" checkbox
    ... The first subroutine of my sample code will work with what you are doing ... The second subroutine is for checkboxes in Userforms, ... Unless you need to visually see all checkboxes with checkmarks in them, ... UserForm checkboxes may test the Controls collection like this: ...
    (microsoft.public.word.vba.beginners)
  • Re: "Check All" checkbox
    ... The first subroutine of my sample code will work with what you are doing ... The second subroutine is for checkboxes in Userforms, ... Unless you need to visually see all checkboxes with checkmarks in them, ... UserForm checkboxes may test the Controls collection like this: ...
    (microsoft.public.word.vba.beginners)
  • Datarepeater and Radiobuttons
    ... list of cities and let the user choose wether it should be included in the ... query or not by switching a radiobutton. ... Maybe that happened due to unbound checkboxes. ...
    (microsoft.public.vb.database)
  • centering checkboxes
    ... I have a worksheet where I add checkboxes on each row so I can decide ... wether to include that row in my calculations. ... Set myRange = Selection ...
    (microsoft.public.excel.programming)