Dynamic Checkbox.Check Problem

G

gwilliam

Problem with checkboxes in webpages. I am trying to re-set the values
of dinamically created checkboxes in a web page, but no matter what I
try the "Checked" property is not set correctly.
A control on the page does a PostBack which in turn calls the following
code:

strSQL = "usp_TradeShow_GetAllAttendeeClasses_Sel " &
lblHiddenUserID.Text & ", " & intSemSchedule
dsTempDataSet = wsMain.GetData(strSQL, strdBase, "TSAttendees")
tblAttendees.Rows.Clear()
'Dim chkList1 As New CheckBoxList
For intCount = 0 To
dsTempDataSet.Tables("TSAttendees").Rows.Count - 1
Dim rAttendeeRow As New TableRow
Dim cAttendeeCell As New TableCell
With cAttendeeCell
'chkList1.Items.Add(New
ListItem(dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("Attendee"),
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("UserID")))
Dim chkList1 As New CheckBox
chkList1.Text =
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("Attendee")
chkList1.ID = "Chk" &
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("UserID")
chkList1.EnableViewState = False
'chkList1.Checked =
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("SignUp")
'If
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("SignUp") = 1
Then
'chkList1.Items(intCount).Selected = True
'Else
' chkList1.Items(intCount).Selected = False
'End If
If
dsTempDataSet.Tables("TSAttendees").Rows(intCount).Item("SignUp") = 1
Then
chkList1.Checked = True
Else
chkList1.Checked = False
End If
chkList1.Font.Name = "Verdana"
cAttendeeCell.Controls.Add(chkList1)
'chkList1.Font.Size = "9"
End With
rAttendeeRow.Cells.Add(cAttendeeCell)
tblAttendees.Rows.Add(rAttendeeRow)
Next

This code creates a checkbox control with the Checked value depending
on a database field, then places the control on a cell, then on a row
and finally it adds it to the table. The first time around it is
perfect, how ever any postback after that does not re-set the
checkbox.checked value. I have followed to code and notice that the
correct values are being set, however the page renders incorrect.

Any help would be greatly appreciated
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top