0
我希望能夠編輯我的選擇菜單項的顯示文本。我仍然希望選擇菜單將來自Traveler的Id作爲值和Name作爲顯示值。不過,我想連接的顯示值與我的旅行模式不同的列稱爲目的地在選擇列表中連接顯示的選項的兩個記錄值
SelectList TravelersList = new SelectList(db.Travelers.Where(c => c.TravelerId == ThisId), "Id", "Name");
foreach(var item as TravelersList)
{
//Concatenate the Traveler Name with the Destination
}
ViewBag.Travelers = TravelersList;
在.Select()之前添加.AsEnumerable()之後,這回答了我的問題。謝謝! –