samedi 31 octobre 2015

foreach checkboxes assign value

Currently, I have a Table, to facilitate appointment booking, based on the data from the Dataset.

The table columns is based on the number of Table Data from [Object] and rows is from 9am to 9pm, 1 row per hour.

For each rows, I've added checkbox : for eg: if users checked checkboxes from 2-6, then I will be blocking off the timeslots

                foreach (DataRow objectrow in ds.Tables["Object"].Rows)
                {
                    myTableCell = new TableCell();
                    CheckBox cb = new CheckBox();
                    myTableCell.Controls.Add(cb);
                    myTableRow.Cells.Add(myTableCell);
                }

However, I have problems assigning the id of the checkboxes and I'm confused on how to achieving it due to multiple objects in the database.

To test the codes, I've assigned Label.Text to check whether any checkboxes is selected. I've tried looping through foreach(rows) then (cell) then (Control) but still wasn't able to get it to work.

Appreciate any feedback as I'm new at programming




Aucun commentaire:

Enregistrer un commentaire