dynamic checkbox

  • Thread starter Thread starter James Wong
  • Start date Start date
J

James Wong

Dear Sir,

I want to create some dynamic checkbox controls into the table.
How can I get these controls after the form is submitted.
-----------------------------------------------------
e.g.
For i = 1 to 9
trwRow = New TableRow
chkCheckBox = New CheckBox
chkCheckBox.ID = "c" + CStr(i)
tclCell = New TableCell
tclCell.Controls.Add(chkCheckBox)
trwRow.Cells.Add(tclCell)
Next
 
Hi,

How about this code:

for (int i = 0; i < 9; i++)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
CheckBox chkCheckBox = new CheckBox

chkCheckBox .Attributes.Add("runat", "Server");
chkCheckBox .EnableViewState = true;
chkCheckBox .ID = "chkCheckBox " + i;

tc.Controls.Add(chkCheckBox );
tr.Cells.Add(tc);
table.Rows.Add(tr);
}

Thanks and Regards,
manish bafna
 
Dear Eliyahu Goldin,

Thanks a lot.

James


Eliyahu Goldin said:
James,

You have to recreate dynamically created controls on every postback.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


James Wong said:
Dear Sir,

I want to create some dynamic checkbox controls into the table.
How can I get these controls after the form is submitted.
-----------------------------------------------------
e.g.
For i = 1 to 9
trwRow = New TableRow
chkCheckBox = New CheckBox
chkCheckBox.ID = "c" + CStr(i)
tclCell = New TableCell
tclCell.Controls.Add(chkCheckBox)
trwRow.Cells.Add(tclCell)
Next
 
Back
Top