0
我有一個Kendo UI Grid,它應該顯示從實體框架加載的鏈接到SQL數據庫的數據。一切工作正常,但突然間數據停止顯示在網格中。Kendo UI Grid不顯示數據庫中的數據
所以,我有:
Index.cshtml
@(
Html.Kendo().Grid<Localidade>()
.Name("LocalidadesGrid")
.Columns(
column =>
{
column.Bound(e => e.nome).Title("Nome").Groupable(false).Width(70);
column.Bound(e => e.cod_postal).Title("Código Postal").Groupable(false).Width(30);
column.Command(command => { command.Edit().Text("Editar").UpdateText("Guardar").CancelText("Cancelar");
command.Destroy().Text("Remover"); }).Width(172);
}
)
.ToolBar(toolbar => toolbar.Create().Text("Criar Nova Localidade"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Filterable()
.Selectable()
.Sortable()
.Pageable(page =>
page.Refresh(true)
.PageSizes(true)
.PreviousNext(true)
.Messages(m => m.ItemsPerPage("Localidades por página")
.Display("{0}-{1} de {2}")
.First("Primeira página")
.Last("Última página")
.Previous("Página anterior")
.Next("Página seguinte"))
)
.Reorderable(reorder => reorder.Columns(true))
.DataSource(
datasource => datasource
.Ajax()
.PageSize(10)
.Model(model => { model.Id(p => p.id); model.Field(p => p.id).Editable(false); })
.Create(update => update.Action("EditingInLine_Create", "Localidades"))
.Read(read => read.Action("GetLocalidades", "Localidades"))
.Update(update => update.Action("EditingInLine_Update", "Localidades"))
.Destroy(update => update.Action("EditingInLine_Destroy", "Localidades"))
)
)
LocalidadesController.cs
private quest_geralEntities db = new quest_geralEntities();
public ActionResult GetLocalidades([DataSourceRequest] DataSourceRequest request)
{
return Json(db.Localidade.ToDataSourceResult(request));
}
調用GetLocalidades時,從LocalidadesController它給了我一個內部服務器錯誤。我也試着返回一個JsonResult而不是一個ActionResult,但是錯誤沒有解決。
編輯:
我在輸出中得到這樣的:
The thread 'Win32 Thread' (0x1024) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1020) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xaf8) has exited with code 0 (0x0).
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Extensions.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll
查看內部服務器錯誤的詳細信息。如果可能,請發佈堆棧跟蹤。 – Jefraim
我編輯了VS輸出給我的最初問題。 – Kevin04PT
在'GetLocalidades'方法中,執行** var db = new quest_geralEntities(); **。 –