dynamic checkbox

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
 
G

Guest

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
 
J

James Wong

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
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top