0

I am not sure if this is duplicate, or either I am asking the right direction, still to be sure I thought why not asking the GURU's.

So I have this enum in my model

public enum LienRequirement
{
    AbstractJudgment=1,
    AbstractSupportJudgment=2,
    Affidavit=3,
    Agreement=4,
    AgriculturalExempt=5
}

And here is my Model:

public class AbstractJudgment
{
    [Key]
    public int AbstractJudgmentId { get; set; }
    public LienRequirement LienRequirementId { get; set; }

    [ForeignKey("Reports")]
    [Display(Name = "Report")]
    public int ReportId { get; set; }
    public virtual Reports Reports { get; set; }
}

I am using MVC 5 Controllers with views, using Entity Framework. So In my create view, I am getting a dropdown for the property *

LientRequirementID

given in the screenshot below: Screenshot

*

I simply want the

Agreement

or perhaps any other options to be selected.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
tatasisi
  • 39
  • 8
  • For the moment I have just thought of a simple solution, I have just hard coded: – tatasisi Dec 28 '17 at 08:16
  • What is the exact list of items you want in the drop down? – dev8989 Dec 28 '17 at 08:50
  • Are you trying to make this as a non-nullable field and the user has to select one of the following in this list? – dev8989 Dec 28 '17 at 08:51
  • Show the create `GET` action method code, so others can guide you fast. – Shaiju T Dec 28 '17 at 10:58
  • @dev8989 the exact list is quite big, I have just used around 7 - 8 samples for example. I want a certain index to be selected that's it. say Assignment from the dropdown should be selected when the page is loaded[check the screenshot]. – tatasisi Dec 28 '17 at 11:57
  • When you say you want a want a certain index to be selected, do you want it to be the same for everyone or like an update page that changes to previous selections? Help me understand this. – dev8989 Dec 28 '17 at 13:44
  • @dev8989 no.. not same. It should be dynamic. – tatasisi Dec 29 '17 at 05:16
  • I'm still confused a bit. What determines the default values then? Geolocation, log in, type of user, explain some more. Show the GET method as well. Do you always want Assignments no matter what selected? – dev8989 Dec 29 '17 at 19:37
  • This looks to be a duplicate of https://stackoverflow.com/questions/388483/how-do-you-create-a-dropdownlist-from-an-enum-in-asp-net-mvc – Darthchai Feb 11 '18 at 23:30

0 Answers0