我想顯示一個確認信息時,用戶從這個我實現網格刪除記錄刪除記錄的確認消息,但我有錯誤消息顯示器上對來自網格
與記錄下面的代碼刪除但:
- 記錄仍然在網格中我不得不刷新看到它失去了;
我有消息錯誤!即使記錄被刪除 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