Solved

checvk box list and for each loop

Posted on 2012-04-10
2
239 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
Comment Utility
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
Comment Utility
Thank you sir
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now