|
 |
aspx thread: adding checkbox at runtime to a table cell, access checkbox id ?
Message #1 by "yvonne" <yvonne.dickson@p...> on Fri, 29 Mar 2002 13:35:46
|
|
hi all,
below is a snippet which builds a table and adds a checkbox for each
childrow in a DataRelation. On the post back I can't figure out how to
iterate through the checkboxes to collect the ids of the ones that are
checked. I am using C# and feeling fairly dumb, I have achieved this as a
test when they are added at design time, but fall down sobbing when done
at runtime.
foreach(DataRow thetype in types)
{
CheckBox checkBox1 = new CheckBox();
checkBox1.Text = thetype["type_name"].ToString();
checkBox1.ID = thetype["id"].ToString();
checkBox1.EnableViewState=true;
TableRow row2 = new TableRow();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
cell2.Controls.Add(checkBox1);
cell3.Text = " ";
row2.Cells.Add(cell3);
row2.Cells.Add(cell2);
Table1.Rows.Add(row2);
}
Message #2 by "Harish" <harish@h...> on Fri, 29 Mar 2002 09:11:31 -0600
|
|
You could access the check boxes as the way you created, meaning, loop thru
for each
childrow in a DataRelation on the post back and see if each check box is
checked.
Harish.
-----Original Message-----
From: yvonne [mailto:yvonne.dickson@p...]
Sent: Friday, March 29, 2002 1:36 PM
To: ASP+
Subject: [aspx] adding checkbox at runtime to a table cell, access
checkbox id ?
hi all,
below is a snippet which builds a table and adds a checkbox for each
childrow in a DataRelation. On the post back I can't figure out how to
iterate through the checkboxes to collect the ids of the ones that are
checked. I am using C# and feeling fairly dumb, I have achieved this as a
test when they are added at design time, but fall down sobbing when done
at runtime.
foreach(DataRow thetype in types)
{
CheckBox checkBox1 = new CheckBox();
checkBox1.Text = thetype["type_name"].ToString();
checkBox1.ID = thetype["id"].ToString();
checkBox1.EnableViewState=true;
TableRow row2 = new TableRow();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
cell2.Controls.Add(checkBox1);
cell3.Text = " ";
row2.Cells.Add(cell3);
row2.Cells.Add(cell2);
Table1.Rows.Add(row2);
}
Message #3 by Yvonne Dickson <Yvonne.Dickson@p...> on Fri, 29 Mar 2002 15:06:53 -0000
|
|
Thanks Harish,
I am using the following method which does the job:
HttpRequest r;
r = this.Request;
// cycle through all the keys in the returned Request
for (int i = 0; i < r.Form.Keys.Count; i++)
{
string k = r.Form.Keys[i];
//do stuff
}
-----Original Message-----
From: Harish [mailto:harish@h...]
Sent: 29 March 2002 15:12
To: ASP+
Subject: [aspx] RE: adding checkbox at runtime to a table cell, access
checkbox id ?
You could access the check boxes as the way you created, meaning, loop thru
for each
childrow in a DataRelation on the post back and see if each check box is
checked.
Harish.
-----Original Message-----
From: yvonne [mailto:yvonne.dickson@p...]
Sent: Friday, March 29, 2002 1:36 PM
To: ASP+
Subject: [aspx] adding checkbox at runtime to a table cell, access
checkbox id ?
hi all,
below is a snippet which builds a table and adds a checkbox for each
childrow in a DataRelation. On the post back I can't figure out how to
iterate through the checkboxes to collect the ids of the ones that are
checked. I am using C# and feeling fairly dumb, I have achieved this as a
test when they are added at design time, but fall down sobbing when done
at runtime.
foreach(DataRow thetype in types)
{
CheckBox checkBox1 = new CheckBox();
checkBox1.Text = thetype["type_name"].ToString();
checkBox1.ID = thetype["id"].ToString();
checkBox1.EnableViewState=true;
TableRow row2 = new TableRow();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
cell2.Controls.Add(checkBox1);
cell3.Text = " ";
row2.Cells.Add(cell3);
row2.Cells.Add(cell2);
Table1.Rows.Add(row2);
}
|
|
 |