astafate
asked on
How to retrieve checked values from databound checkedlistbox windows vb.net
I have a Checkedistbox bound to a dataset. I need to get out the checked selecteditemvalue from each one that is checked to get send to my insert query for another table. this is multi select. I need code for selectedindexchages of a button onclick either one will do. thank you.
here is my code on popluating the checklistbox1
Dim myconn As OleDbConnection = New OleDbConnection(Cnn)
Dim mydap As New OleDbDataAdapter
Dim dbcom As OleDbCommand
Dim mydsLmat As New DataSet
Dim strSQL As String
strSQL = "SELECT PickID, PickName FROM Picklist WHERE Picktype = 'O' OR Picktype = 'C'"
Try
CheckedListBox1.DataSource = Nothing
dbcom = New OleDbCommand(strSQL, myconn)
mydap = New OleDbDataAdapter(dbcom)
myconn.Open()
CheckedListBox1.Items.Clea r()
mydsLmat = New DataSet
mydap.Fill(mydsLmat, "Picklist")
CheckedListBox1.DisplayMem ber = ("PickName").ToString
CheckedListBox1.ValueMembe r = ("PickID").ToString
CheckedListBox1.DataSource = mydsLmat.Tables(0)
myconn.Close()
Catch ex As Exception
MsgBox(ex.Message)
mydsLmat.Dispose()
End Try
here is my code on popluating the checklistbox1
Dim myconn As OleDbConnection = New OleDbConnection(Cnn)
Dim mydap As New OleDbDataAdapter
Dim dbcom As OleDbCommand
Dim mydsLmat As New DataSet
Dim strSQL As String
strSQL = "SELECT PickID, PickName FROM Picklist WHERE Picktype = 'O' OR Picktype = 'C'"
Try
CheckedListBox1.DataSource
dbcom = New OleDbCommand(strSQL, myconn)
mydap = New OleDbDataAdapter(dbcom)
myconn.Open()
CheckedListBox1.Items.Clea
mydsLmat = New DataSet
mydap.Fill(mydsLmat, "Picklist")
CheckedListBox1.DisplayMem
CheckedListBox1.ValueMembe
CheckedListBox1.DataSource
myconn.Close()
Catch ex As Exception
MsgBox(ex.Message)
mydsLmat.Dispose()
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.