ViewBag.TopicInfoID = new SelectList(db.TopicInfo, "TopicInfoID", "TopicName", strategycategory.TopicInfoID);

            var list = db.StrategyCategory.Where(p => p.StrategyCategoryParentID == "0").ToList();
            list.Insert(0, new StrategyCategory() { StrategyCategoryID = "0", StraegyCategoryName = " -- 请选择 -- " });
            SelectList sList = new SelectList(list, "StrategyCategoryID", "StraegyCategoryName",strategycategory.StrategyCategoryParentID);
            ViewBag.StrategyCategoryParentID = sList; 
 @Html.DropDownList("TopicInfoID", String.Empty)
 @Html.DropDownList("StrategyCategoryParentID", String.Empty)

备注:

1、

ViewBag.TopicInfoID中的TopicInfoID和@Html.DropDownList("TopicInfoID", String.Empty)方法中的第一个参数一样

2、
 ViewBag.StrategyCategoryParentID = sList; 

 @Html.DropDownList("StrategyCategoryParentID", String.Empty)





相关文章:

  • 2021-08-06
  • 2021-07-29
  • 2022-12-23
猜你喜欢
  • 2021-10-29
  • 2021-07-24
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案