Dynamic Checkbox.Check Problem

Discussion in 'ASP .Net' started by gwilliam, Aug 25, 2006.

  1. gwilliam

    gwilliam Guest

    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
     
    gwilliam, Aug 25, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    930
    Mark Rae
    Dec 5, 2006
  2. JB
    Replies:
    1
    Views:
    553
  3. Terje
    Replies:
    5
    Views:
    385
    Evertjan.
    Nov 18, 2004
  4. pizzy
    Replies:
    0
    Views:
    169
    pizzy
    Mar 23, 2005
  5. pizzy
    Replies:
    5
    Views:
    387
    pizzy
    Apr 12, 2005
Loading...

Share This Page