Cannot select checkboxes in checkboxlist within repeater.

Discussion in 'ASP .Net' started by Ratman, Jun 29, 2004.

  1. Ratman

    Ratman Guest

    I have the following function that created a checkboxlist and "is
    supposed" to be checking values that are already saved in the
    database. As I step thru the code, it is in fact marking the
    approporiate checkboxes as checked as I watch them in the watch windo
    and I see the execution of the code go into the appropriate code
    blocks. The problem is, the checkboxes are not being checked on th
    UI. Any ideas here? This function is being called on the Item
    created event of my repeater. My repeater contains a label, for the
    category, and a checkboxlist, for the subcategories.

    Private Sub cblSubCategoryDataBind(ByVal Item As RepeaterItem)

    Dim lCategoryID As Integer = CType(CType(CType(Item.DataItem,
    DataRowView).Row, DataRow)("CategoryID"), Integer)

    Dim oSubCategoryID As CheckBoxList
    oSubCategoryID = CType(Item.FindControl("cblSubCategoryID"),
    CheckBoxList)

    Dim oCategory As New GDCDB.category

    oSubCategoryID.DataValueField = "SubCategoryID"
    oSubCategoryID.DataTextField = "SubCategory"
    oSubCategoryID.DataSource =
    oCategory.GetAllSubCategoriesByCategoryID(lCategoryID)
    oSubCategoryID.DataBind()

    oCategory = Nothing

    'go thru checkboxes for this category and check any that are
    checked in the DB
    Dim oPiece As New GDCDB.piece
    oPiece.PieceID = CType(txtPieceID.Text, Integer)

    Dim oDs As New DataSet
    oDs = oPiece.SelectAllSubCategoriesByPieceID(lCategoryID)

    Dim oDataRow As DataRow
    Dim oLi As ListItem

    For Each oDataRow In oDs.Tables(0).Rows

    If Not (oDataRow.IsNull("Selected")) Then
    oLi =
    oSubCategoryID.Items.FindByValue(CType(oDataRow("SubCategoryID"),
    String))
    oLi.Selected = True
    Else
    oLi =
    oSubCategoryID.Items.FindByValue(CType(oDataRow("SubCategoryID"),
    String))
    oLi.Selected = False
    End If

    Next

    oLi = Nothing
    oDataRow = Nothing
    oDs = Nothing
    oPiece = Nothing

    End Sub

    Help me please!

    Thanks in advance.
     
    Ratman, Jun 29, 2004
    #1
    1. Advertising

  2. If you have smartNavigation on then turn it off. Then close the browser
    and navigate to the link again. Then do a View Source and see what is
    wrong. You can post the code here.

    Regards,

    Trevor Benedict R
    MCSD

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Trevor Benedict R, Jun 30, 2004
    #2
    1. Advertising

  3. Ratman

    Ratman Guest

    Actually, what I did was move my function call from the OnItemCreated
    event to the OnItemDayaBound event of the repeater and now it works.
    Thanks anyways.

    JDA
     
    Ratman, Jul 4, 2004
    #3
    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. JD
    Replies:
    5
    Views:
    11,676
    NetArchitect
    Aug 8, 2007
  2. sianan
    Replies:
    5
    Views:
    1,210
    S. Justin Gengo
    Oct 27, 2005
  3. angus
    Replies:
    1
    Views:
    189
    angus
    May 6, 2004
  4. Matt
    Replies:
    2
    Views:
    209
    Roland Hall
    Jan 11, 2004
  5. Toboja
    Replies:
    3
    Views:
    104
    Toboja
    Jan 3, 2005
Loading...

Share This Page