【发布时间】:2011-08-27 00:41:08
【问题描述】:
在我的控制器中,我有以下内容(为简洁起见省略了代码):
public ActionResult Edit(string id)
{
vw_user u = _respository.getProfile(id);
var model = new UserProfileEditViewModel
{
SL_collegeid = new SelectList(_respository.getColleges(u.State), "id", "college1", u.id)
};
return View(model);
}
现在,当我在返回之前调试模型时,它显示在 SelectList (SL_collegeid) 中选择了特定的大学 (u.id)。但是,当页面加载时,选择的项没有被选中。
这是cshtml的代码:
@Html.DropDownListFor(model=>model.SL_collegeid, Model.SL_collegeid)
有人可以帮我解决这个问题吗?
提前谢谢你, 克里斯
【问题讨论】:
标签: asp.net-mvc razor html.dropdownlistfor