I wanted to put dropdownlist
in my view where its List value was for the database, but I know only how to add values to DropDownlist
with data from a table, I wanted to make a DropDownlist
with three values without having to create a new table and put it in my View Razor.
Here is an example of what I do in my views:
@model BlogWeb.ViewsModels.VisitaModel
@Html.ValidationMessage("DtIntegracao.Invalido")
@Html.ValidationMessageFor(v => v.Nome)
@Html.LabelFor(v => v.Nome, "Nome:")
@Html.TextBoxFor(a => a.Nome)
@Html.ValidationMessageFor(v => v.Rg)
@Html.LabelFor(v => v.Rg, "Rg:")
@Html.TextBoxFor(a => a.Rg)
@Html.ValidationMessageFor(v => v.DtIntegracao)
@Html.LabelFor(v => v.DtIntegracao, "Data Integração:")
@Html.TextBoxFor(v => v.DtIntegracao, "{0:dd-MM-yyyy}", new { Type = "date" })
@Html.ValidationMessageFor(v => v.ResponsavelId)
@Html.LabelFor(v => v.ResponsavelId, "Responsavel Entrada:")
@Html.DropDownListFor(v => v.ResponsavelId, new SelectList(ViewBag.Usuarios, "Id", "Nome"))