How to get "condition" from objects set in a cell?

G

Guest

Ok, long story short, I've done this:

TableRow tmRow = new TableRow();
tblCreditCards.Rows.Add(tmRow);
int a = 0;
while (a < 3)
{
TableCell tmCell = new TableCell();
tmRow.Cells.Add(tmCell);
CheckBox chk = new CheckBox();
chk.Text = "This is a test for #" + a;
chk.ID = Convert.ToString(a);
tmCell.Controls.Add(chk);
tmRow.Cells.Add(tmCell);
a++;
}


And I want to be able to retrieve the CHECKED condition on all three of the
checkboxes.

I've tried to determine how I'm supposed to get that value, but I can't seem
to figure it out.

This is where I'm at now:

string temp = Convert.ToString(tmRow.Cells.Count);
Response.Write("<script language='Javascript1.2'>alert('" + temp +
"')</script>");

temp = (Convert.ToString(tmRow.Cells[1].Controls[1].Count));
Response.Write("<script language='Javascript1.2'>alert('" + temp +
"')</script>");


In the last one, I'm trying to get to the properties of the "chk" control.

Wouldn't it be something like this?


Boolean boolTempBoolean = (tmRow.Cells[1].Controls[chk].Checked);

???


Thanks guys...


Todd
 
M

Mark Rae

Wouldn't it be something like this?

Boolean boolTempBoolean = (tmRow.Cells[1].Controls[chk].Checked);

Try this:

Boolean boolTempBoolean =
((CheckBox)tmRow.Cells[1].FindControl("chk")).Checked;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top