我有一个mvc razor视图,这个视图包含几个记录。现在如何在jquery对话框中获取记录以进行更新。我没有根据“路由ID”获取记录,因为它是5并且没有数据ID 5.我应该将它用于ajax还是我可以解决这个问题而不是使用ajax?
页面详细信息如下。
EmployeeDetail.cshtml
网址:EmployeeDetail / 5
@model EmployeeCvBank.EmployeeRepository
人:Irakli Zuradze
部门:IT /软件开发人员
+ Add new education
+------+--------------------------------+----------------+-------------------+
| ID | Education | Graduate | Actions |
+------+--------------------------------+----------------+-------------------+
| 1 | Batumi University Msc | 1/7/2012 | Edit / Delete |
+------+--------------------------------+----------------+-------------------+
| 2 | Tbilisi State University Ms | 25/9/2010 | Edit / Delete |
+------+--------------------------------+----------------+-------------------+
编辑和删除教育知识的操作
public ActionResult EditEducation(PersonEducation model)
{
...
}
public ActionResult DeleteEducation(int id)
{
...
}
public class EmployeeRepository
{
public Employee Employee {get;set;}
public Education Education {get;set;}
}
答案 0 :(得分:0)
如果我没有错,你想修改拥有Id 5的用户的教育细节吗?
总有办法
<强>步骤强>
创建隐藏字段,该字段将在表单提交中保留您的教育ID。
@Html.Hidden("EducationId")
将onclick事件添加到“编辑”链接
<a href="javascript:PopulateHiddenFieldsBeforeSubmit('@education.id')" >Edit</a>
<script>
function PopulateHiddenFieldsBeforeSubmit(educationId)
{
$("#EducationId").val(educationId);//prove hidden educationid field with selected value
document.forms[0].submit();
}
装饰员工后期行动
Public ActionResult EmployeeDetail(EmployeeRepository collection, int EducationId)
{
//Now you have desired educationid here
}