Solved

checvk box list and for each loop

Posted on 2012-04-10
2
241 Views
Last Modified: 2012-04-10
I have a check box list I want to loop through the list and get  the value of each item selected and insert each item into the database individualy does any one know how to do this

    Protected Sub ddlFIlterType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlFIlterType.SelectedIndexChanged
        If (ddlFIlterType.SelectedItem.ToString = "Department") Then
            getDepartment()
            'Response.Write("I got it to click")
        ElseIf (ddlFIlterType.SelectedItem.ToString = "City Office") Then
            getCity()
        ElseIf (ddlFIlterType.SelectedItem.ToString = "Job") Then
            getJob()
        ElseIf (ddlFIlterType.SelectedItem.ToString = "Region") Then
            getRegion()
        End If
    End Sub

Open in new window

And this is my fill for the cblValues

   Public Sub getDepartment()
        Try
            Dim ds As DataSet = Nothing
            ds = SqlHelper.ExecuteDataset(appSecurity.getConnection(), CommandType.StoredProcedure, "SP")
            Me.cblValues.DataSource = ds.Tables(0)
            Me.cblValues.DataTextField = "dept_nm"
            Me.cblValues.DataValueField = "deptid"
            Me.cblValues.DataBind()
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

Open in new window



Thanks
0
Comment
Question by:r3nder
2 Comments
 
LVL 14

Accepted Solution

by:
binaryevo earned 500 total points
ID: 37828888
For Each MyItem in cblValues.Items
        If MyItem.Selected = True Then
             'insert code goes here
        End If
    Next

Open in new window

0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 37829069
Thank you sir
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question