本文介绍了如何在ASP.NET中的索引页面上创建表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在Visual Studio中构建一个ASP.NET MVC应用程序。我是新手,并且很难在索引页面上构建表单。我希望人们能够选中一个框并点击保存按钮,而不必转到单独的编辑页面。字段Keane和orsos是可检查字段。我编写了函数并调用了save方法并刷新了页面,但我保存的内容都没有保存。任何帮助将不胜感激!





Hello, I am building an ASP.NET MVC application in Visual Studio. I am new to this and am having a hard time building a form right onto the index page. I want people to be able to check a box and hit the save button instead of having to go to a separate edit page. The fields "Keane" and "orsos" are the checkable fields. I have written the function and the save method is called and the page refreshes, but nothing I change is saved. Any help would be appreciated!


@using (Html.BeginForm("save", "drnos"))
{
    {
<input type="submit" value="Save" />
<table>
    <tr>
<th>
     @Html.ActionLink("RVH ID", "Index", new { sortOrder = ViewBag.IDSortParm })
</th>
<th>
    @Html.ActionLink("Keane", "Index", new { sortOrder = ViewBag.KeaneSortParm })
</th>
<th>
    @Html.ActionLink("Orsos", "Index", new { sortOrder = ViewBag.OrsosSortParm })
</th>

 @foreach (var item in Model)
    {
<td>
        @Html.DisplayFor(modelItem => item.RVH_ID_)
</td>
<td>
        @Html.EditorFor(modelItem => item.Keane)
        @Html.ValidationMessageFor(modelItem => item.Keane)
</td>
<td>
       @Html.EditorFor(modelItem => item.Orsos)
       @Html.ValidationMessageFor(modelItem => item.Orsos)
</td>
 </td>
   </tr>
    }
</table>
}
}










[HttpPost]
        public ActionResult Save(Doctor doc)
        {
             System.Diagnostics.Debug.WriteLine("Save Called");

             db.Entry(doc).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
        }

推荐答案


这篇关于如何在ASP.NET中的索引页面上创建表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:21
查看更多