• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

checvk box list and for each loop

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
r3nder
Asked:
r3nder
1 Solution
 
binaryevoCommented:
For Each MyItem in cblValues.Items
        If MyItem.Selected = True Then
             'insert code goes here
        End If
    Next

Open in new window

0
 
r3nderAuthor Commented:
Thank you sir
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now