In my model I have a property called Reasons
. I want the user to be able to select from a small list of reasons. The list will look something like this:
PR Promotional
CL Customer Related
SL Supplier Related
I have tried using an enum for this, but I can't seem to get it working. Intellisense won't recognize Reasons
as a property of my model when I try to hook it up with my model (yes, it is set to public
). What would be the best approach to this? I definitely don't think using a database is necessary in this case and I'd rather avoid using one. Thanks for any help. I'm using ASP.NET MVC 5.
EDIT-- Update on the issue
After some more testing, I've realized that the issue is occurring because of the way that my ViewModel is set up. My ViewModel contains a property that references one of my other models, which references all of the other models. I have written the classes with the objective of serializing them to XML based on a predetermined XML structure. Here is an example:
<MyViewModel>
<Property>
</Property>
<ReferenceToOtherModel>
<OtherModel1>
<ReferenceToOtherModel2>
</ReferenceToOtherModel2>
</OtherModel1>
</ReferenceToOtherModel>
</MyViewModel>
To summarize this, MyViewModel
is the root of the XML structure, so I am unable to put a property in the ViewModel itself that serves as a link to the enum.
EDIT 2:
The error message I'm getting is something like this: "model.otherModel1.otherModel2.Reasons is a type, which is not valid in the given context. Reasons: cannot reference a type through an expression; try 'otherModel2.Reasons' instead."
Unfortunately, othermodel2 cannot be referenced without fully qualifying the name, which goes back to the first sentence of the error message.