错误状态:'内部服务器错误'。错误代码:500在MVC4中JQgrid编辑和删除

编程入门 行业动态 更新时间:2024-10-25 02:26:26
本文介绍了错误状态:'内部服务器错误'。错误代码:500在MVC4中JQgrid编辑和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我开始使用JQgrid,它可以正常添加,搜索和所有,但是当我删除记录时,我的帖子告诉我错误。 它没有进入删除和编辑控制器操作本身,我通过在那里提供断点检查。 我的代码看起来像查看 {

Hi i started working on JQgrid, and it works fine for add,search and all, but when i delete the record its fetching me the error as my post says. its not entering to the delete and edit controller action itself, i checked by putting break points in there. My code looks like View {

<table id="jQGridDemo"> </table> <div id="jQGridDemoPager"> </div> <script type="text/javascript"> jQuery("#jQGridDemo").jqGrid({ url: 'RTGUser/GetUserDetails', datatype: "json", colNames: ['Id', 'Name', 'Designation', 'City'], colModel: [ { name: 'Id', index: 'Id', width: 40, align:'center', sortable: true, editable:false}, { name: 'Name', index: 'Name', width: 40, align: 'center', sortable: true, editable: true, edittype: 'text', editrules: { required: true} }, { name: 'Designation', index: 'Designation', width: 400, align: 'center', sortable: true, editable: true, edittype: 'text', editrules: { required: true} }, { name: 'City', index: 'City', width: 150, align: 'center', sortable: true, editable: true, edittype: 'text', editrules: { required: true} } ], mtype: 'POST', loadonce: true, rowList: [5,10, 20, 30], pager: '#jQGridDemoPager', sortname: 'Id', viewrecords: true, sortorder: 'desc', caption: "List Of Users" }); jQuery("#jQGridDemo").jqGrid('navGrid', '#jQGridDemoPager', { edit: true, add: true, del: true, search:true }, { url: "/RTGUser/EditUser", closeAfterEdit: true, beforeShowForm: function (formid) { $("#Id", formid).hide(); } }, { url: "/RTGUser/AddNewUser", closeAfterAdd: true, beforeShowForm: function (formid) { $("#Id", formid).hide(); } }, { url: "/RTGUser/DeleteUser" }, {}); $("#search").filterGrid("#grid", { gridModel: false, filterModel: [{ label: 'Search', name: 'search', stype: 'text' }] }); </script> </body>

}

,我的控制器看起来像 {

and my controller looks like {

public ActionResult EditUser(int userId, string name, string desig, string city) { try { var query = from u in db.Users where u.Id.Equals(userId) select u; var user = query.First(); user.Name = name; user.Designation = desig; user.City = city; db.SaveChanges(); return Json(true); } catch (Exception) { // Do some error logging stuff, handle exception, etc. return Json(false); } } public ActionResult DeleteUser(int userId) { try { var query = from u in db.Users where u.Id.Equals(userId) select u; // var user = query.First(); var usr = db.Users.Find(Convert.ToInt32(userId)); db.Users.Remove(usr); db.SaveChanges(); return Json(true); } catch (Exception e) { // Do some error logging stuff, handle exception, etc. Response.Write(e); return Json(false); } }

} 请建议我解决这个问题。

} please suggest me the way to solve this.

推荐答案

使用的Firefox / Firebug的或IE8的开发者工具来看看你是从服务器获取实际响应。它在哪一行呢?一旦你发现,你可能会发现你的错误。

Use Firefox/Firebug or the IE8 developer tools to look at the actual response you are getting from the server. On what line does it fall over? Once you find out, you'll probably find your error.

更多推荐

错误状态:'内部服务器错误'。错误代码:500在MVC4中JQgrid编辑和删除

本文发布于:2023-11-24 10:33:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624853.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   错误代码   状态   编辑   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!