0

Hi friends i am trying to bring a data from the field in an checkboxlist. I have successfully done this. Now i am not able to get the values of selected items...........plz help me
i am using following code to bind checkboxlist with my database

Public Sub getchkbox()
        Dim myConnection As OleDbConnection
        Dim strSQL As String
        Dim myadpt As OleDbDataAdapter
        'Dim Dset As New DataSet
        Dim datatab As New DataTable

        myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Server.MapPath("App_Data\Domain_Management1.mdb") & "';Persist Security Info=True")
        strSQL = "select [PFirstName]from Partyinfo"
        'Dim strConString As String
        'strConString = System.Configuration.ConfigurationManager.AppSettings("Admin_Password")
        'myConnection = New OleDbConnection(strConString)
        myConnection.Open()
        myadpt = New OleDbDataAdapter(strSQL, myConnection)
        myadpt.Fill(datatab)
        SelecteduserCheckBoxList.DataTextField = "PFirstName"
        SelecteduserCheckBoxList.DataValueField = "PFirstName"
        SelecteduserCheckBoxList.DataSource = datatab
        SelecteduserCheckBoxList.DataBind()
End Sub

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jbisono
0

you have to create a foreach loop like this

foreach(ListItem li in SelecteduserCheckBoxList.Items)
{
    if(li.Selected)
    {
        String itemSelect = li.Text;
    }
}

regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.