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. 2 6372
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(object Sender, Eventargs e)
{
BindMyGrid(); //or whatever code you use to populate your repeater
}
Change it too:
void Page_Load(object Sender, Eventargs e)
{
if(!Page.IsPostBack)
BindMyGrid(); //or whatever code you use to populate your repeater
}
HTH
"Andrew" <An****@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.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(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.
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.IsPostBack) 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.checked 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(RepeaterItem r in MyRepeater.Items)
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(object Sender, Eventargs e) { BindMyGrid(); //or whatever code you use to populate your repeater }
Change it too:
void Page_Load(object Sender, Eventargs e) { if(!Page.IsPostBack) BindMyGrid(); //or whatever code you use to populate your repeater }
HTH
"Andrew" <An****@discussions.microsoft.com> wrote in message news:6F**********************************@microsof t.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(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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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"...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |