jeudi 26 novembre 2015

Create Checkbox (or checkboxlist) from a list using foreach

I am trying to make a checkbox or checkboxlist from a list. i tried:

@foreach (var bundle in Model.BundleList)
{

    <div>
        <input type="checkbox" name="labels" value="@bundle.BundleType" id="@bundle.BundleType" />
        <label for="@bundle.BundleType">@bundle.BundleType</label>
    </div>
} 

but how can i know which checkbox is selected? i also want to have radiobutton behaviour, which mean only one checkbox can be selected.




Aucun commentaire:

Enregistrer un commentaire