@Html.DropDownListFor(model => model.Status, new List<SelectListItem>
{ new SelectListItem{Text="Active", Value="True"},
new SelectListItem{Text="Deactive", Value="False"}})
In view I am using this drop dowenlist coding. I run my application default deactive value is display in dropdown list box. I want display default Active
I hope this is helpful to you.
Please try this code,
SelectListItem
has aSelected
property. If you are creating theSelectListItem
s dynamically, you can just set the one you want asSelected = true
and it will then be the default.try this
Like this:
If you want Active to be selected by default then use
Selected
property ofSelectListItem
:If using
SelectList
, then you have to use this overload and specifySelectListItem
Value
property which you want to set selected: