Checkboxlist why is this not working

  • Thread starter Thread starter Mr. SweatyFinger
  • Start date Start date
M

Mr. SweatyFinger

Dim adapter As New System.Data.OleDb.OleDbDataAdapter(cmd, conn)

Dim ds As New System.Data.DataSet

adapter.Fill(ds)

Dim row As System.Data.DataRow

Dim i As Integer

Dim catName As String

For Each row In ds.Tables(0).Rows

catName = row.Item(0)

Response.Write(catName & "<br>")

Dim cbl As CheckBoxList = formview1.FindControl("CheckBoxList1")

If Not cbl.items.FindByValue(row.Item(0).tostring) Is Nothing Then

cbl.items.FindByValue(row.Item(0).tostring).selected = True
<===================Not working

End If

'cbl.items()

'listitem.

i += 1

Next
 
You dont really say, what error you are getting. Take things a step at a
time.

Does your list box contain the element you are searching for ?
You can check this by right clicking over the rendered web page displayed in
your browser and choosing view source. look for the rendered control data
and see if the value is actually there.

If not then thats one, thing, if it is, then we need to ook further into it.
 
cbl.items.FindByValue(row.Item(0).tostring).selected = True
<===================Not working

((CheckBox)cbl.items.FindByValue(row.Item(0).tostring)).selected = True
 
Back
Top