and I have a dropdown list which looks something like
@Html.DropDownListFor(model => model.ChildItems[i].RestrictionValue,
from Project.Core.Enums.Items.Restriction state in Enum.GetValues(typeof(Project.Core.Enums.Items.Restriction))
select new SelectListItem() { Text = state.ToString(), Value = ((int)state).ToString() }
,"Select", Model.ChildItems[i].RestrictionValue
)
but when there is no value select I get the error
Nullable object must have a value.
is there a way that the selected field can have a 0 value? or is there another work arround
EnenDaveyBoy
Participant
1465 Points
1146 Posts
dropdown list default value
May 09, 2012 02:07 PM|LINK
I have a mode which has a int? value
and I have a dropdown list which looks something like
@Html.DropDownListFor(model => model.ChildItems[i].RestrictionValue,
from Project.Core.Enums.Items.Restriction state in Enum.GetValues(typeof(Project.Core.Enums.Items.Restriction))
select new SelectListItem() { Text = state.ToString(), Value = ((int)state).ToString() }
,"Select", Model.ChildItems[i].RestrictionValue
)
but when there is no value select I get the error
Nullable object must have a value.
is there a way that the selected field can have a 0 value? or is there another work arround