From reading many tutorials on how to set up drop down menus on various sites I've managed to piece a few things together but am still stuck.
I've been told that my code below should be contained in a View Model, currently it is at the top of my View:
var genderItems = new List<ListItem>
{
new ListItem { Text = "Unisex", Value = "0" },
new ListItem { Text = "Female", Value = "1" },
new ListItem { Text = "Male", Value = "2" }
};
var statusItems = new List<ListItem>
{
new ListItem { Text = "Inactive", Value = "0" },
new ListItem { Text = "Active", Value = "1" }
};
In the same View I have been using this code to generate a drop down box:
@Html.DropDownList("RoomGender", new SelectList(genderItems, "Value", "Text", Model.RoomGender))
Could somebody please explain how I am supposed to abstract this and then pass it to the view without removing the already attached Room
model which I have, as that is the Model which models the data for the database.
This is probably quite simple and I have tried researching it, but I really am struggling to piece it all together.