On 7 Jul, 23:56, "Elliot" <elliot_barc...@hotmail.co.ukwrote:
I use the following way to generate a table with a checkbox each row:
* * * * * * TableRow rowA;
* * * * * * for (int i = 1; i<=10 ; i++)
* * * * * * {
* * * * * * * * rowA = new TableRow();
* * * * * * * * cellA = new TableCell();
* * * * * * * * CheckBox CB = new CheckBox();
* * * * * * * * cellA.Controls.Add(CB);
* * * * * * * * row.Cells.Add(cellA);
* * * * * * * * rowA.Cells.Add(cellA);
* * * * * * }
How can I give those 10 checkboxs different value & how can I obtain them?
You need to run the TableRow construction routine during the Page_Load
event every time (both on the initial page request and during post
back). Thereafter the CheckBox states will be available via the Table
object (presumably declared in page source or globally within the
webform class definition) in any event handler for postback. By
default ViewState is enabled for WebControls and the matching of
CheckBoxes in ViewState with those re-created during Page_load will
occur automatically (ASP.NET uses automatically generated the clientID
for this).
Try it and see
Good luck