gtjr92
05-18-2005, 12:03 AM
http://forums.asp.net/Themes/default/images/spacer.gif
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
http://forums.asp.net/Themes/default/images/icon_toolbar_right.gif
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
http://forums.asp.net/Themes/default/images/icon_toolbar_right.gif