后台:  public ActionResult EditorInterface() 
        {            return View();
        
        }
        [HttpPost]
        public ActionResult Content()
        {
            GridDataContext grid = new GridDataContext();            string Id = Request.Form["Id"];
            string MenuName = Request.Form["MenuName"];
            string ApplicationId = Request.Form["ApplicationId"];
            string Levels = Request.Form["Levels"];            ViewData["Id"] = Id;
            ViewData["MenuName"] = MenuName;
            ViewData["ApplicationId"] = Id;
            ViewData["Levels"] = Levels;
            return View("EditorInterface");
        }
前台:<body>
    <div>
   
         <table class="编辑菜单">
       <tr>
        <td>ID:</td>
        <td><input type="text" class="Id"  value='<%:ViewData["Id"]%>' disabled/></td>
        <td><label style="color:red"></label></td>
      </tr>
    <tr>
        <td>菜单名:</td>
        <td><input type="text" class="MenuName" value='<%:ViewData["MenuName"]%>' /></td>
        <td><label style="color:red">*该选项不允许为空</label></td>
      </tr>
      <tr>
        <td>应用Id:</td>
        <td><input type="text" class="ApplicationId" value='<%:ViewData["ApplicationId"]%>' /></td>
        <td><label style="color:red">*该选项不允许为空</label></td>
      </tr>
      <tr>
        <td>级别:</td>
        <td><input type="text" class="Levels" value='<%:ViewData["Levels"]%>' /></td>
        <td><label style="color:red">*该选项不允许为空</label></td>
      </tr>
    </table> 
      
    </div>
</body>
怎么不显示

解决方案 »

  1.   

    ViewData["MenuName"]在显示的时候  .ToString()
      

  2.   

    1. 你的前台HTML这个View叫什么名字?
    2. 既然是编辑页面,EditorInterface是否是你的取数据的方法?
    3. 你这个MVC感觉有点不对。
      

  3.   

    贴个Edit的例子吧Controller下:public ActionResult Edit(int id)
            {
                return View(list.First(n => n.Id == id));
            }
            [HttpPost]
            public ActionResult Edit(int id, FormCollection formValues)
            {
                NewsModel news = list.First(n => n.Id == id);
                UpdateModel<NewsModel>(news);
                return RedirectToAction("Details", new { id = id });
            }
    View:<h2>Edit</h2>    <% using (Html.BeginForm()) {%>
            <%: Html.ValidationSummary(true) %>
            
            <fieldset>
                <legend>Fields</legend>
                
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Id) %>
                </div>
                <div class="editor-field">
                    <%: Html.LabelFor(model => model.Id) %>
                    <%: Html.ValidationMessageFor(model => model.Id) %>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Title) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(model => model.Title) %>
                    <%: Html.ValidationMessageFor(model => model.Title) %>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Content) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(model => model.Content) %>
                    <%: Html.ValidationMessageFor(model => model.Content) %>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Author) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(model => model.Author) %>
                    <%: Html.ValidationMessageFor(model => model.Author) %>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.CreateTime) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(model => model.CreateTime, String.Format("{0:g}", Model.CreateTime)) %>
                    <%: Html.ValidationMessageFor(model => model.CreateTime) %>
                </div>
                
                <p>
                    <input type="submit" value="Save" />
                </p>
            </fieldset>    <% } %>