473,839 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

capturing checkbox.checke d in repeater control

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(Repeate rItem r in MyRepeater.Item s)
{
for (int i=1; i<=6; i++) //6 checkboxes
{
CheckBox chk = (CheckBox)r.Fin dControl("chkbo x"+ 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.Data Item, "choiceA").ToSt ring() != "" %>' >
</asp:CheckBox>
</ItemTemplate>
<FooterTemplate >
</Table>
</FooterTemplate>
</ASP:REPEATER>

TIA.
Andrew.

Nov 19 '05 #1
2 6461
Are you binding this in the Page_Load ??

Be sure to use the Page.IsPostBack method in your pageload.
Otherwise, the Repeater will keep getting reset, and all your checkboxes
will be in there default value (unchecked)

So, if you code looks something like this:

void Page_Load(objec t Sender, Eventargs e)
{
BindMyGrid(); //or whatever code you use to populate your repeater
}

Change it too:

void Page_Load(objec t Sender, Eventargs e)
{
if(!Page.IsPost Back)
BindMyGrid(); //or whatever code you use to populate your repeater
}

HTH

"Andrew" <An****@discuss ions.microsoft. com> wrote in message
news:6F******** *************** ***********@mic rosoft.com...
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(Repeate rItem r in MyRepeater.Item s)
{
for (int i=1; i<=6; i++) //6 checkboxes
{
CheckBox chk = (CheckBox)r.Fin dControl("chkbo x"+ 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.Data Item, "choiceA").ToSt ring() != "" %>' >
</asp:CheckBox>
</ItemTemplate>
<FooterTemplate >
</Table>
</FooterTemplate>
</ASP:REPEATER>

TIA.
Andrew.

Nov 19 '05 #2
U are right I am. I load the ds in the page_load, from there I call a method
BindRepeater(), which will load the repeater with the ds.datatable.

I already have the: if(!Page.IsPost Back) in my page_load. When I run the
program, I used the debugger n i detect that after i click the Next button,
the program calls the BindRepeater() method again, which will explain why i
get checkbox.checke d false values each time.

So what I did for testing sake was to take away the BindRepeater method n
just insert its code straight into the Page_load. I used the debugger n saw
that when it reaches:
foreach(Repeate rItem r in MyRepeater.Item s)
it just skips past this loop n proceed on.
I wonder why, hmmmm ...

TIA.
Andrew.

---------------------------------------------------------------------------------
"Grant Merwitz" wrote:
Are you binding this in the Page_Load ??

Be sure to use the Page.IsPostBack method in your pageload.
Otherwise, the Repeater will keep getting reset, and all your checkboxes
will be in there default value (unchecked)

So, if you code looks something like this:

void Page_Load(objec t Sender, Eventargs e)
{
BindMyGrid(); //or whatever code you use to populate your repeater
}

Change it too:

void Page_Load(objec t Sender, Eventargs e)
{
if(!Page.IsPost Back)
BindMyGrid(); //or whatever code you use to populate your repeater
}

HTH

"Andrew" <An****@discuss ions.microsoft. com> wrote in message
news:6F******** *************** ***********@mic rosoft.com...
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(Repeate rItem r in MyRepeater.Item s)
{
for (int i=1; i<=6; i++) //6 checkboxes
{
CheckBox chk = (CheckBox)r.Fin dControl("chkbo x"+ 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.Data Item, "choiceA").ToSt ring() != "" %>' >
</asp:CheckBox>
</ItemTemplate>
<FooterTemplate >
</Table>
</FooterTemplate>
</ASP:REPEATER>

TIA.
Andrew.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2093
by: Alan Silver | last post by:
Hello, I have a repeater with a list of products in it. Each item in the repeater has a checkbox, allowing the product to be selected. When a link button is clicked, I want to loop through the repeater and handle each product whose checkbox is checked. The repeater looks (greatly chopped down) like this... <asp:Repeater ID="rptProducts" RunAt="Server">
2
5525
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox and subcategory check boxes and click on submit button , I have to retrieve the corresponding categoryid and subcategory id, so that I can store it to a table. I am getting the categoryid but I am failing to get subcategoryid(actually I don't know...
8
16626
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below the repeater. When clicked, it is supposed to
2
3724
by: RichardH | last post by:
Hi, I have x number of table rows that all should have a checkbox and a dropdownlist on each row. The checkbox could be checked and the dropdown should contain y number of values that are related to the row. I can't find a good control for this in ASP.Net 2.0. Now I use a repeater and check the checkbox on ItemDataBound, I also fill the dropdown on this event. My first problem is that i find this event very messy. I have to cast...
0
2815
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
0
2290
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
5
24530
by: c_shah | last post by:
using VB.net (2005) ASP.net 2.0 I have a repeater control with the item template, in the item template I have two checkboxes How to capture event When user checks the checkboxes? What event fires on the repeater Repeater Control Item Template
1
1914
by: Doogie | last post by:
Why is this code not allowing me to add a checkbox to it? <asp:repeater ID="RptTrip" Runat="server" EnableViewState="false"> <ItemTemplate> <asp:Checkbox AutoPostBack="True" ID="cb" runat="server" Checked="false"></asp:Checkbox> <trip_detail_info trip_detail_id ='<%# Container.DataItem("trip_detail_id")%>' leg_start_dt = '<%# Container.DataItem("leg_start_dt")%>' pickup_iso_dt = '<%# Container.DataItem("pickup_iso_dt")
3
2917
by: Mahathi | last post by:
Hi I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that. My requirement is that "I have to map some roles with that of the users of the project. I have used checkboxes for selecting the roles that a particular user has. For example, an adminstrator has all roles in an organisation. Similarly an Employee has limited roles. Here let us take administrator...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10656
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.