using a detailsview and a radiobutton checklist- trying to loop through checkboxlist and collect the values separating with a comma (I want to add them to one field in a SQL table)
This is in my code behind page...
in my default.aspx page I have it binding to the session variable... then inserting the value of the variable to SQL- only takes the first one selected, not looping... help!
Insert parameters:
call on the checkboxlist itself:
Code:
Protected Sub HChkEvents_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim HChkEvents As String = String.Empty
Dim c As CheckBoxList = CType(DetailsView1.FindControl("HChkEvents"), CheckBoxList)
Dim item As ListItem
For Each item In c.Items
If item.Selected Then
HChkEvents = HChkEvents + item.Text.ToString & ","
End If
Next
Session.Add("achieve", HChkEvents)
End Sub
This is in my code behind page...
in my default.aspx page I have it binding to the session variable... then inserting the value of the variable to SQL- only takes the first one selected, not looping... help!
Insert parameters:
Code:
<InsertParameters>
<asp:ControlParameter ControlID="HRegID" Name="HRegID" PropertyName="Text" Type="String" />
<asp:Parameter Name="HRegName" Type="String" />
<asp:Parameter Name="HRegArrival" Type="String" />
<asp:Parameter Name="HRegDepart" Type="String" />
<asp:FormParameter FormField="HRegRoom" Name="HRegRoom" />
<asp:Parameter Name="HSharingWith" Type="String" />
<asp:Parameter Name="HRegBadge" Type="String" />
<asp:SessionParameter Name="HChkEvents" SessionField="achieve" />
</InsertParameters>
call on the checkboxlist itself:
Code:
<asp:TemplateField HeaderText="Events">
<InsertItemTemplate>
<asp:CheckBoxList ID="HChkEvents" runat="server" RepeatDirection="Horizontal" Width="416px" SelectedValue='<%# Bind("achieve") %>' OnSelectedIndexChanged="HChkEvents_SelectedIndexChanged">
<asp:ListItem Value="Sunday Kick Off Reception">Sunday Kick Off Reception</asp:ListItem>
<asp:ListItem Value="Monday Cont. Breakfast">Monday Cont. Breakfast</asp:ListItem>
<asp:ListItem Value="Monday Lunch">Monday Lunch</asp:ListItem>
<asp:ListItem Value="Tuesday Breakfast">Tuesday Breakfast</asp:ListItem>
<asp:ListItem Value="Thursday Luncheon">Thursday Luncheon</asp:ListItem>
</asp:CheckBoxList>
</InsertItemTemplate>
</asp:TemplateField>