467,136 Members | 1,336 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,136 developers. It's quick & easy.

cannot detect the repeater

Hi,

I display a repeater in a web page, when i click on the next button, I want
to loop thru the repeater to detect the checkbox controls. Previously this
code works, but now .... I used the debugger n found that the program cannot
even detect the repeater control coz it just skips past this line. I have
listed a abbrev. version of my code below:

private void btnNext_Click(object sender, System.EventArgs e)
{
tstdAnswer = "";
try
{
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 == true)
{
tstdAnswer += "1";
}
else
tstdAnswer += "0";
}
}
}
}

TIA.
Andrew.
Nov 19 '05 #1
  • viewed: 906
Share:
2 Replies
Andrew,

Probably you mean MyRepeater.Items is empty rather than there is no
repeater, otherwise you would get an exception.

Anyway, check EnableViewState properties for the page and for the repeater
and check the data populating logic in Page_Load .

Eliyahu

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
Hi,

I display a repeater in a web page, when i click on the next button, I want to loop thru the repeater to detect the checkbox controls. Previously this
code works, but now .... I used the debugger n found that the program cannot even detect the repeater control coz it just skips past this line. I have
listed a abbrev. version of my code below:

private void btnNext_Click(object sender, System.EventArgs e)
{
tstdAnswer = "";
try
{
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 == true)
{
tstdAnswer += "1";
}
else
tstdAnswer += "0";
}
}
}
}

TIA.
Andrew.

Nov 19 '05 #2
Use RepeaterItem r in MyRepeater.Items.Controls(0)

Regards,
Sachin Saki
..NET Developer - Capgemini, INDIA
"Eliyahu Goldin" ने लिखा:
Andrew,

Probably you mean MyRepeater.Items is empty rather than there is no
repeater, otherwise you would get an exception.

Anyway, check EnableViewState properties for the page and for the repeater
and check the data populating logic in Page_Load .

Eliyahu

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
Hi,

I display a repeater in a web page, when i click on the next button, I

want
to loop thru the repeater to detect the checkbox controls. Previously this
code works, but now .... I used the debugger n found that the program

cannot
even detect the repeater control coz it just skips past this line. I have
listed a abbrev. version of my code below:

private void btnNext_Click(object sender, System.EventArgs e)
{
tstdAnswer = "";
try
{
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 == true)
{
tstdAnswer += "1";
}
else
tstdAnswer += "0";
}
}
}
}

TIA.
Andrew.


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.