checkboxlist not passing correct values...

Discussion in 'ASP.NET 2.0' started by gtjr92, May 18, 2005.

  1. [​IMG]







    I am trying to iterate through a checkbox list and insert new record into a table. the Sub i have inserts a listbox selected value and a checkbox list selected value. Both are bound to a DB.
    When I run the first code below the data is inserted, however it inserts the same ckWKIDval for each of the selected items. I want it to see all of the selected item values and enter them along with the lbxpeople val.
    I.E. if i have 3 boxes checked it only passes the first box that is checked and it passes that value 3 times. When it should pass 3 different values for each wkidval check box.


    Sub Peopleup(ByVal sender As Object, ByVal e As EventArgs)
    Dim ckWeeks As ListItem
    For Each ckWeeks In ckbxWeeks1.Items
    If ckWeeks.Selected Then
    Dim lbxPeopleval As Integer = lbxPeople.SelectedValue
    Dim ckWKIDval As Integer = ckbxWeeks1.SelectedValue
    asdWeeks2.InsertParameters.Add("PeoIDparam", lbxPeopleval)
    asdWeeks2.InsertParameters.Add("WKIDparam", ckWKIDval)
    asdWeeks2.Insert()
    asdWeeks2.InsertParameters.Clear()
    End If
    Next
    End Sub


    Thanks




    [​IMG]
     

Share This Page