Me podrían ayudar con este error asp.net The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
este es mi codigo
controlador
public ActionResult GetData()
{
using (SISTEMAUSGEntities db = new SISTEMAUSGEntities())
{
List<PROYECTOS> empList = db.PROYECTOS.ToList<PROYECTOS>();
return Json(new { data = empList }, JsonRequestBehavior.AllowGet);
}
}
[HttpGet]
public ActionResult AddOrEdit(int id = 0)
{
if (id == 0)
return View(new PROYECTOS());
else
{
using (SISTEMAUSGEntities db = new SISTEMAUSGEntities())
{
return View(db.PROYECTOS.Where(x => x.IDPROJECT == id).FirstOrDefault<PROYECTOS>());
}
}
}
vista
<a class="btn btn-success" style="margin-bottom:10px" onclick="PopupForm('@Url.Action("AddOrEdit","Project")')"><i class="fa fa-plus"></i> Add New</a>
<table id="ProjectTable" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>NAMEPROJECT</th>
<th>NUMPART</th>
<th>TIPOMATE</th>
<th>PAIS</th>
<th>NUMFACTURA</th>
<th>PESOPALLET</th>
<th>NUMPALLET</th>
<th>FECHA</th>
<th>STATUSPROJECT</th>
<th></th>
</tr>
</thead>
</table>
<link href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
@section scripts{
<script src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min.js"></script>
<script>
var Popup, dataTable;
$(document).ready(function () {
dataTable = $("#ProjectTable").DataTable({
"ajax": {
"url": "/Project/GetData",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "NAMEPROJECT" },
{ "data": "NUMPART" },
{ "data": "TIPOMATE" },
{ "data": "PAIS" },
{ "data": "NUMFACTURA" },
{ "data": "PESOPALLET" },
{ "data": "NUMPALLET" },
{ "data": "FECHA" },
{ "data": "STATUSPROJECT" },
{ "data": "IDPROJECT" , "render" : function (data) {
return "<a class='btn btn-default btn-sm' onclick=PopupForm('@Url.Action("AddOrEdit","Project")/" + data + "')><i class='fa fa-pencil'></i> Edit</a><a class='btn btn-danger btn-sm' style='margin-left:5px' onclick=Delete("+data+")><i class='fa fa-trash'></i> Delete</a>";
},
"orderable": false,
"searchable": false,
"width": "150px"
}
],
"language": {
"emptyTable": "No data found, Please click on <b>Add New</b> Button"
}
});
});