Another one of these questions regarding DropDownListFor
not selecting the \"Selected\" value.
Here is code:
Model:
Ok, let's discuss about your example, when PermissionId
was int. You posted model of type CreateEditAccountModel
to view. When you created this model, PermissionId
equal 0 (default value of int). And DropDownListFor
in view get this value. Therefore you had no selected values.
When you used string type, default value of PermissionId
was null, therefore `DropDownListFor taken default value of SelectList.
In this case it's better to use int?
or Nullable
type for PermissionId
.