Solved

checvk box list and for each loop

Posted on 2012-04-10
2
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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