我想从数据库中输入一个值,因为我的下拉列表已经有一个与文本相同的值,所以我想要一个与我的文本分开或不同的值。示例代码= 1,text =病理学家。
我的控制器:
public ActionResult MainHistopathologyForm(string id)
{
var patientprofileViewModel = new MDHPIStables();
patientprofileViewModel.histopathology = db.histopathology.Find(id);
patientprofileViewModel.roles = db.roles.Find(Session["role"]);
var PathologistList = new List<string>();
var PathologistQry = from d in db.pathologist
select d.pathologist;
PathologistList.AddRange(PathologistQry.Distinct());
TempData["pathologistlist"] = new SelectList(PathologistList);
return View(patientprofileViewModel);
}
MainHistopathologyForm.cshtml:
@Html.Partial("RolesHistopathologyForm", Model.roles, new ViewDataDictionary())
@Html.Partial("Partial_HistopathologyForm", Model.histopathology,
new ViewDataDictionary())
Partial_HistopathologyForm:
@{
ViewBag.concurring1 = TempData["pathologistlist"];
}
@Html.DropDownList("concurring1", "Select Pathologist")
答案 0 :(得分:0)
@ Html.DropDownList(&#34;您的ViewBag名称&#34;,null,&#34;选择列表&#34;,新{@class =&#34;表单控件&#34;,required =& #34;必需&#34;})