1
I have a checkbox list and need to bind values that are strings (@item.Selectedvalue) with my Ienumerable>.
<div class="editor-field perfil-filtro-expander-todasAcoes">
<div class="metro perfil-filtro-expander-overflow todasAcoes" id="todasAcoes" name="todasAcoes">
@foreach (DetailedLookupModel<string> item in (IEnumerable<DetailedLookupModel<string>>)ViewBag.Acoes)
{
<div style="padding-bottom: 10px;">
@*<input id="@item.SelectedValue" type="checkbox" name="@item" value="@item.SelectedValue"/>*@
@Html.TextBoxFor(x => Model.Acoes, new { @type = "checkbox", @id = item.SelectedValue, @value = item.SelectedValue})
<label for="@item.SelectedValue">
<b>@item.Title</b>
<br />
<span class="perfil-filtro-expander-descricao">
@item.Description
</span>
</label>
</div>
}
</div>
@Html.ValidationMessageFor(model => model.Descricao)
</div>
Property of the Model:
[DisplayName("Ações")]
[Required]
public IEnumerable<DetailedLookupModel<String>> Acoes { get; set; }
This way I can get the checboxes, but the value of them was to be the "value"
all comes null
. Nor can I make changes to the Abels, as my css depends on those ids
to understand which are the Abels for the appropriate fields.
You’ve seen it here?
– Leonel Sanches da Silva
Worse than already, I tried to use but I found some flaws, it would not be nice I have to change the architecture to have the list of selected items being that I can get through a viewbag with a bank return. Also the "title" field of the helper only accepts a given, I needed to style this value with my css as I already did there. Any solution you know alternative?
– Luiz Negrini
Enter here: http://chat.stackexchange.com/rooms/25342/c-asp-net-asp-net-mvc-entity-framework-etc
– Leonel Sanches da Silva