My ModelClass in
Public class Employee
{
public SelectList PublishMonth { get; set; }
}
On view, it display as dropdown and working fine. Now on another partial view, i need to display all employee. I get List and i need to display value of PublishMonth for each employee. if i display like <%=item.PublishMonth.SelectedValue%>
it display ID instead of text. How can i get text?
I would do something like this:
in the view:
Then when you post the form, the selected value will be binded in the Month property.
When you build your SelectList, I supposed you have something that sets the DisplayValue of the item.
I will suppose it is an extension method on an int
In the view I would do: