Hi I am trying to add checkbox in my drop downlist. I googled it and I am getting example in asp.net as I am trying to do in MVC3. On my form edit User must be able to check values in the dropdown list. For example in below form for manufactures list currently it is just displaying values I must provide with a checkbox associated with that value.
My form:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<EmsAdmin.Models.User>" %>
<%@ Import Namespace="EmsAdmin.Models" %>
<script type="text/javascript">
//<![CDATA[
// Focus on the first input box for the site
$(document).ready(function () {
$('#UserId').focus();
});
//]]>
</script>
<%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<%= Html.AntiForgeryToken() %>
<p>
<%= Html.LabelFor(e=>e.Id,"Id:") %>
<%: Model.Id %>
</p>
<p>
<%= Html.LabelFor(e=>e.PersonId,"Person:") %>
<%= Html.DropDownListFor(e => e.PersonId, (SelectList)ViewData["allPersons"], "Select a person", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.Person,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.Email,"Email:") %>
<%= Html.TextBoxFor(e => e.Email, new { @style = "width:250px;" })%>
<%= Html.ValidationMessageFor(e=>e.Email,"") %>
</p>
<%= Html.LabelFor(e=>e.Approve,"Aprrove User:") %>
<%= Html.CheckBoxFor(e=> e.Approve,Model.Approve) %><span> Switch this on if you want to add regitrar </span>
<%= Html.ValidationMessageFor(e=>e.Approve,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.ManufacturerDescription,"Brand:") %>
<%= Html.DropDownListFor(e => e.ManufacturerDescription, (SelectList)ViewData["allManufacturers"], "Select Brands", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.ManufacturerDescription,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.CountryName,"Country:") %>
<%= Html.DropDownListFor(e => e.CountryName, (SelectList)ViewData["allCountries"], "Select Countries", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.CountryName,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.Role,"Role:") %>
<%= Html.DropDownListFor(e => e.Role, (SelectList)ViewData["allRoles"], "Select Roles", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.Role,"") %>
</p>
<p>
<input type="submit" value="Save" />
<%= Html.ActionLink("Cancel","Details",new {id=Model.Id},new {@title="exit without saving"}) %>
</p>
<% } %>
<p>above yourApprove User:(noticed while I reformatted)