很难将所选值粘贴在 ASP.NET MVC 页面上。
public partial class AdjustedCost
{
public SelectList BrandList { get; set; }
public string Brand { get; set; }
}
BrandList 正在控制器中设置:
private static SelectList BrandList = new SelectList( new[] { "Brand1","Brand2","Brand3" } );
public ActionResult EditByTextbox(String textBoxEdit)
{
...
AjustedCost xadjcost = db.xAdjCost.First(e => e.InvtId == textBoxEdit);
...
xadjcost.BrandList = BrandList;
return View( "Edit", xadjcost);
}
在编辑视图中:
@Html.DropDownListFor(model => model.Brand, Model.BrandList )
这个对吗?下拉部分正在工作,但所选值仅返回列表顶部,而不是当前设置的实际值。