Link to home
Start Free TrialLog in
Avatar of nkoriginal
nkoriginalFlag for Spain

asked on

VB.net Populate CHECKBOXLIST

Hello to all...
I've a little problem when I try to selected my checkbox list with the retrieve data from sql DB.

I've a checkbox list, created with an objectdatasource in asp.net
then in the code behind (vb.net) I try to select, the item in the checkboxlist with the Id's coming from the DB.
with this code nothing nothing happen. I know the problem is in the "for each" line, but I dont know how to define the code to look trought my items and then populate.

I tried in the checkboxlist databinding and in the page_load event
Thanks for any help

Here is my code

        ponentesAsignados = New DataSetTableAdapters.ponentesAsignadosTableAdapter
        Dim ponentesAsignados_data As DataSet.ponentesAsignadosDataTable = ponentesAsignados.SelectByProId(proId)
        If ponentesAsignados_data.Count > 0 Then

            For Each l As ListItem In ponModId.Items
                If l.Value = ponentesAsignados_data(0).ponId.ToString() Then
                    l.Selected = True
                End If
            Next
        End If
ponentesAsignados = New DataSetTableAdapters.ponentesAsignadosTableAdapter
        Dim ponentesAsignados_data As DataSet.ponentesAsignadosDataTable = ponentesAsignados.SelectByProId(proId)
        If ponentesAsignados_data.Count > 0 Then 
            For Each l As ListItem In ponModId.Items
                If l.Value = ponentesAsignados_data(0).ponId.ToString() Then
                    l.Selected = True
                End If
            Next
        End If

Open in new window

Avatar of bklmnsh
bklmnsh
Flag of Ukraine image

Here is sample code. Please let me know if I misunderstood your question and you have other problem
ASKER CERTIFIED SOLUTION
Avatar of bklmnsh
bklmnsh
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nkoriginal

ASKER

thanks for your answer. Where I suposse to put it? in the load or in the databound?

Thanks
It not was the complete solution, but help me to find the correct solution to my problem.
thanks