I'd like to populate a Html.DropDownListFor with both static and dynamic values in my controller. I can't seem to figure out how to make this work. I've tried a few different approaches, but most center around (1) define the static values in a variable, (2) try to append the dynamic values (3) pass all values via the viewModel to my partial view.
Here is a sample of the above approach.
//retrieve categories from DB
List<Category> categoryFromDb = new GetCategory().GetCategoryDropdownList(MySession.Current.AccountId).FindAll(c => c.StageId == currentStage);
//local variable with static values and trying to add the dynamic values from above
var categoryDropDown = new [] {
new {CategoryId = "", CategoryName = "Select Activity"},
new {CategoryId = "0", CategoryName = "Note"},
new {CategoryId = categoryFromDb[0], CategoryName = categoryFromDb[3]} //THIS IS THE LINE I CAN'T FIGURE OUT
};
var viewModel = new ActivityTimelineViewModel
{
ActivityTimeline = new GetActivity().GetActivityTimeline(MySession.Current.AccountId, MySession.Current.CandidateId),
CategoryList = categoryDropDown,
Date = DateTime.Today
};
I'm sure given my novice ability I am missing something simple. -Tim