nkoriginal
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.ponen tesAsignad osTableAda pter
Dim ponentesAsignados_data As DataSet.ponentesAsignadosD ataTable = ponentesAsignados.SelectBy ProId(proI d)
If ponentesAsignados_data.Cou nt > 0 Then
For Each l As ListItem In ponModId.Items
If l.Value = ponentesAsignados_data(0). ponId.ToSt ring() Then
l.Selected = True
End If
Next
End If
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.ponen
Dim ponentesAsignados_data As DataSet.ponentesAsignadosD
If ponentesAsignados_data.Cou
For Each l As ListItem In ponModId.Items
If l.Value = ponentesAsignados_data(0).
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
Here is sample code. Please let me know if I misunderstood your question and you have other problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for your answer. Where I suposse to put it? in the load or in the databound?
Thanks
Thanks
ASKER
It not was the complete solution, but help me to find the correct solution to my problem.
thanks
thanks