I am working with an asp.net website and I need to use a drop down list with checkboxes.
I have this written in HTML that works, however I want a more elegent solution in getting the values to the code behind and retaining the values other than using Request.Form()
The code I am using to generate the drop down list currently and return the information is as below.
<div class="btn-group">
<a class="btn btn-default dropdown-toggle btn-select" data-toggle="dropdown" href="#">Report Status <span class="caret"></span></a>
<ul class="dropdown-menu">
<asp:PlaceHolder ID="statusSelectorPlaceHolder" runat="server"></asp:PlaceHolder>
</ul>
</div>
The Html I am generating is being created like this;
Private Shared Function BuildHtmlStatusSelector(dictOfStatus As Dictionary(Of String, String)) As StringBuilder
Dim html As StringBuilder = New StringBuilder
For Each item In dictOfStatus
html.AppendLine(String.Format("<li style='padding-left: 10px'><label class='small' tabindex='-1'><input type='checkbox' id='reportStatus' name='reportStatus' checked='true' value='{0}'/>{1}</label></li>", item.Value, item.Key))
Next
Return html
End Function
When the page posts back I am checking or the values here like so
If Not Request.Form("reportStatus") = Nothing Then
StatusCodes = Request.Form("reportStatus")
End If
its not the most elegant solution and I was hoping that there is a simple and effective asp.net control that i could implement instead so that I dont have to use this method
Im happy with either vb or c# examples as can work with both.
Any and all help would very much be appreciated.