MVC 先后顺序

                    @foreach (var item in Model)
                    {
                        if (ViewBag.GetModel.ParentID == item.DictID)
                        {
                            <option value="@item.DictID" selected="selected">@item.DictType</option>
                        }
                        else
                        {
                            <option value="@item.DictID">@item.DictType</option>
                        }
                    }
  if (id != null) //返回顺序
            {
                DictionaryBLL BLL = new DictionaryBLL();
                ViewBag.GetModel = BLL.GetModel((int)id);
                return View(BLL.GetModelList("ParentID = 0"));
            }
            else
            {
                return Content("错误!");
            }

页面加载顺序

先加载

ViewBag.GetModel.ParentID
在加载
Model
在循环
     @foreach (var item in Model)
posted @ 2018-03-29 09:51  enych  阅读(303)  评论(0编辑  收藏  举报