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