从MVC 4中的数据库填写表单? [英] Fill Form back from database in MVC 4?
问题描述
嗨
我创建了一个视图,其中我称之为两个部分视图。
部分视图1
它包含一个包含多个文本框和下拉列表的表单。
当用户点击提交时按钮数据保存在数据库中,同时显示在部分视图2 中。
部分视图2
在这个局部视图中,我有一个编辑按钮。当用户点击编辑按钮时,应在表格中填写相应的值。我怎样才能做到这一点。我没有使用Entity Framework。没有它我怎么能实现这个目标?
Thanx。
Hi
I have crated a View in which I am calling two partial views.
Partial View 1
It contains a form with multiple textbox and dropdown.
When a user clicks on submit button the data gets saved in database and simultaniously it is displayed in Partial View 2.
Partial View 2
In this partial view I have an edit button. When the user click on the edit button corresponding values should be filled in the form. How can I do this. I am not using Entity Framework. Without it how can I achieve this?
Thanx.
推荐答案
您必须使用所选模型调用编辑的部分视图。
You must call the partialview of edit for with the selected model.
// returning partial
public ActionResult Edit(int idtoedit)
{
//get row to edit and place it in viewdata
return PartialView(editformpartialview, viewdata);
}
这篇关于从MVC 4中的数据库填写表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!