Cannot select checkboxes in checkboxlist within repeater.

R

Ratman

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.
 
T

Trevor Benedict R

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!
 
R

Ratman

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
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top