0
Just so you know, you should never loop through to build strings, they are immutable and this gets very costly.
Use:
StringBuilder sb = new StringBuilder();
foreach(Control co in r.Cells[2].Controls)
{
if (co.GetType() == typeof(Checkbox))
sb.Append((Checkbox)co).Checked.ToString()+"\n";
}
string output = sb.ToString();
0
foreach(Control co in r.Cells[2].Controls)
{
if (co.GetType().Name.ToString() == "Checkbox")
TextBox1.Text+= ((Checkbox)co).Checked.ToString()+"\n";
}
0
Always the same...you post a question then work it out!!
the answer was to use the uniqueid of the control and then use findcontrol to return it. Also needed to cast the control etc. now it all works and heres the code
foreach(Control co in r.Cells[2].Controls)
{
CheckBox cb=(CheckBox)this.FindControl(co.UniqueID);
TextBox1.Text=TextBox1.Text+cb.Checked.ToString()+"\n";
}