我想显示一个确认信息时,用户从这个我实现网格删除记录删除记录的确认消息,但我有错误消息显示器上对来自网格
与记录下面的代码删除但:
- 记录仍然在网格中我不得不刷新看到它失去了;
我有消息错误!即使记录被删除 3.
@Html.ActionLink("Delete Student", "Delete", new { @StudentID = StudentID }, new { @class="glyphicon glyphicon-pencil", @id=StudentID }) $(document).ready(function() { $('a.delete').click(OnDeleteClick); }); function OnDeleteClick(e) { var StudentId = e.target.id; var flag = confirm('You are about to delete this record permanently. Are you sure you want to delete this record?'); if (flag) { $.ajax({ url: '/Home/DeleteRecord', type: 'POST', data: { StudentID: StudentId }, dataType: 'json', success: function (result) { alert(result); $("#" + StudentId).parent().parent().remove(); }, error: function() { alert('Error!'); } }); } return false; }
控制器:
public ActionResult DeleteRecord(string StudentID)
{
//Code to delete
}
return RedirectToAction("StudentGrid",
"Home");
}
我正在使用网格MVC你的代码工作的消息,但网格不刷新 – melom
@melom对不起,我不知道如何刷新GridMVC。我会创建另一个具体的问题。有人会很快回答我确信,我已经很久没有使用它了。 :) – hutchonoid