1
Dropdownlistfor shows no selected value.
public static List<SelectListItem> getMesesPagamento()
{
List<SelectListItem> listMeses = new List<SelectListItem>();
for (byte i = 1; i <= 12; i++)
{
if (i == 6) // Junho
listMeses.Add(new SelectListItem { Text = Utilitario.getMes(i), Value = i.ToString(), Selected = true });
else
listMeses.Add(new SelectListItem { Text = Utilitario.getMes(i), Value = i.ToString() });
}
return listMeses;
}
Na View:
@Html.DropDownListFor(model => model.Pagamento_MesReferencia, Model.MesesPgto, "", htmlAttributes: new { @id = "ddlMesesPgto" })
List Type
model.Pagamento_MesReferencia é do tipo List<SelectListItem>
It does not appear in the View the value you marked in the controller as SELECTED?
– PauloHDSousa
Does not appear selected in View
– Gleison França
Cool this I already know, what does not appear, is what Voce marked Selected colo in the code? it appears as? has how to put print?
– PauloHDSousa
I edited the question and posted the print @Paulohdsousa See that in the code the month is not selected.
– Gleison França
Where do you add the model to your list? puts the code
– PauloHDSousa
public List<Selectlistitem> Mesespgto { get; set; }
– Gleison França