字符串我有我的控制器索引視圖此代碼..如何從下拉列表中
public ActionResult Index(int? id)
{
_viewModel.ServiceTypeListAll = new SelectList(_bvRepository.GetAllServiceTypes().ToList().OrderBy(n => n.ServiceTypeName).ToList(), "ServiceTypeId", "ServiceTypeName");
return View(_viewModel);
}
使用這個我能dispaly所有ServiceTypes在我的下拉列表框視圖。代碼
<%=Html.DropDownList("ServiceTypeListAll", new SelectList(Model.ServiceTypeListAll,"Value","Text"))%>
當我試圖從視圖中選擇的下拉列表值到控制器我acceesing這樣的..
string categoryName = collection["ServiceTypeListAll"]; // collectoin refers FormCollection
我期待類別名稱應該是串像我什麼都在Dropdownlist框中顯示。
我越來越整數值?
是somethign我做錯了
感謝
根本不要調用'ToList()'。 – SLaks 2010-08-19 22:35:30