Asp.net mvc 4 单击“Kendo UI更改数据”;转到下一页;

Asp.net mvc 4 单击“Kendo UI更改数据”;转到下一页;,asp.net-mvc-4,kendo-ui,kendo-grid,Asp.net Mvc 4,Kendo Ui,Kendo Grid,我对剑道和MVC4很陌生。我在网页上的剑道网格上显示数据 在一个页面上,我只允许显示10个项目(行)。但是,当我点击数字“2”时,页面异常失败 我知道我在控制器端丢失了一些代码。但是由于我对MVC4缺乏了解,我不知道在什么地方添加什么。以下是观点: @model IEnumerable<MVC4Trial.Models.vwCallDetail> @{ ViewBag.Title = "Index"; } <h2>Call Detail View<

我对剑道和MVC4很陌生。我在网页上的剑道网格上显示数据

在一个页面上,我只允许显示10个项目(行)。但是,当我点击数字“2”时,页面异常失败

我知道我在控制器端丢失了一些代码。但是由于我对MVC4缺乏了解,我不知道在什么地方添加什么。以下是观点:

   @model IEnumerable<MVC4Trial.Models.vwCallDetail>
@{
    ViewBag.Title = "Index";
}

<h2>Call Detail View</h2>

@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
    {
        columns.Bound(p => p.CCCID).Width(50).Title("CCCID");
        columns.Bound(p => p.Mp3_Url).Width(50).Title("MP3 URL");
        columns.Bound(p => p.Target_Number).Width(50).Title("Target Number");
        columns.Bound(p => p.Duration).Width(50);
        columns.Bound(p => p.Index).Width(50);
        columns.Bound(p => p.LocalTime).Width(50);
        columns.Bound(p => p.Site_Name___Address).Width(50).Title("Site Address");
        columns.Bound(p => p.Ad_Source_Name).Width(50).Title("Ad Source Name");
        columns.Bound(p => p.Tracking_Number).Width(50).Title("Tracking Number");
        columns.Bound(p => p.Caller_Number).Width(50).Title("Caller");
        columns.Bound(p => p.Available_Feature).Width(50).Title("Features");
    })
    .Pageable(page => page.Enabled(true).PageSizes(new Int32[] {10, 20, 30, 40}))
    .Sortable(sorting => sorting.SortMode(Kendo.Mvc.UI.GridSortMode.SingleColumn))
    .Scrollable()
    .Filterable()
    .DataSource(datasource => datasource
        .Ajax()
        .Read(read => read.Action("vwCallDetail", "Grid"))
        )
    .Resizable(resize =>resize.Columns(true))
    .Reorderable(reordering => reordering.Columns(true))   


    ) 
@model IEnumerable
@{
ViewBag.Title=“Index”;
}
调用详细视图
@(Html.Kendo().Grid(模型)
.名称(“网格”)
.列(列=>
{
列.绑定(p=>p.CCCID).宽度(50).标题(“CCCID”);
columns.Bound(p=>p.Mp3_Url).Width(50).Title(“Mp3 Url”);
列。绑定(p=>p.Target_编号)。宽度(50)。标题(“Target编号”);
columns.Bound(p=>p.Duration).Width(50);
columns.Bound(p=>p.Index).Width(50);
columns.Bound(p=>p.LocalTime).Width(50);
columns.Bound(p=>p.Site\u Name\u\u Address).Width(50).Title(“Site Address”);
columns.Bound(p=>p.Ad_Source_Name).Width(50).Title(“Ad Source Name”);
列。绑定(p=>p.Tracking_Number)。宽度(50)。标题(“Tracking Number”);
columns.Bound(p=>p.Caller_Number).Width(50).Title(“Caller”);
columns.Bound(p=>p.Available_Feature).宽度(50).标题(“Features”);
})
.Pageable(page=>page.Enabled(true).PageSizes(新的Int32[]{10,20,30,40}))
.Sortable(sorting=>sorting.SortMode(Kendo.Mvc.UI.GridSortMode.SingleColumn))
.Scrollable()
.可过滤()
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“vwCallDetail”、“Grid”))
)
.resize可调整大小(resize=>resize.Columns(true))
.Reorderable(reordering=>reordering.Columns(true))
) 
下面是控制器代码

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC4Trial.Models;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;

namespace MVC4Trial.Controllers
{
    public class CallTrackController : Controller
    {
        private CallTrackEntities db = new CallTrackEntities();

        //
        // GET: /CallTrack/

        public ActionResult Index()
        {
            return View(db.vwCallDetails.ToList());
        }


        public ActionResult vwCallDetails([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetCallDetails().ToDataSourceResult(request));
        }

        private static IEnumerable<vwCallDetail> GetCallDetails()
        {
            var callDetails = new CallTrackEntities();
            return callDetails.vwCallDetails.Select(vwCallDetail => new vwCallDetail
            {
                CCCID = vwCallDetail.CCCID,
                Mp3_Url = vwCallDetail.Mp3_Url,
                Index = vwCallDetail.Index,
                Target_Number = vwCallDetail.Target_Number,
                Duration = vwCallDetail.Duration,
                LocalTime = vwCallDetail.LocalTime,
                Site_Name___Address = vwCallDetail.Site_Name___Address,
                Ad_Source_Name = vwCallDetail.Ad_Source_Name,
                Tracking_Number = vwCallDetail.Tracking_Number,
                Caller_Number = vwCallDetail.Caller_Number,
                Available_Feature = vwCallDetail.Available_Feature


            });
        }


        public ActionResult Details(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /CallTrack/Create

        [HttpPost]
        public ActionResult Create(vwCallDetail vwcalldetail)
        {
            if (ModelState.IsValid)
            {
                db.vwCallDetails.Add(vwcalldetail);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Edit/5

        public ActionResult Edit(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // POST: /CallTrack/Edit/5

        [HttpPost]
        public ActionResult Edit(vwCallDetail vwcalldetail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(vwcalldetail).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Delete/5

        public ActionResult Delete(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // POST: /CallTrack/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            db.vwCallDetails.Remove(vwcalldetail);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Kendo UI Sample</title>
         <link rel="stylesheet" href="@Url.Content("~/Content/kendo.common.min.css")">
         <link rel="stylesheet" href="@Url.Content("~/Content/kendo.default.min.css")">
         <script src="@Url.Content("~/Scripts/jquery.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.web.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>
         <link href="@Url.Content("~/Content/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
         <script src="@Url.Content("~/Scripts/kendo.dataviz.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>
    </head>
    <body>
        <header>
            <div class="content-wrapper">

                <div class="float-right">
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>

        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>
使用系统;
使用System.Collections.Generic;
使用系统数据;
使用System.Data.Entity;
使用System.Linq;
使用System.Web;
使用System.Web.Mvc;
使用MVC4Trial.Models;
使用Kendo.Mvc.UI;
使用Kendo.Mvc.Extensions;
命名空间MVC4Trial.Controllers
{
公共类CallTrackController:控制器
{
private CallTrackEntities db=new CallTrackEntities();
//
//获取:/CallTrack/
公共行动结果索引()
{
返回视图(db.vwCallDetails.ToList());
}
公共操作结果vwCallDetails([DataSourceRequest]DataSourceRequest请求)
{
返回Json(GetCallDetails().ToDataSourceResult(请求));
}
私有静态IEnumerable GetCallDetails()
{
var callDetails=new CallTrackEntities();
return callDetails.vwCallDetails.Select(vwCallDetail=>new vwCallDetail
{
CCCID=vwCallDetail.CCCID,
Mp3\u Url=vwCallDetail.Mp3\u Url,
Index=vwCallDetail.Index,
Target\u Number=vwCallDetail.Target\u Number,
持续时间=vwCallDetail.Duration,
LocalTime=vwCallDetail.LocalTime,
站点名称地址=vwCallDetail.Site名称地址,
Ad_Source_Name=vwCallDetail.Ad_Source_Name,
追踪号码=vwCallDetail.Tracking号码,
Caller\u Number=vwCallDetail.Caller\u Number,
可用\u功能=vwCallDetail.Available\u功能
});
}
公共操作结果详细信息(int id=0)
{
vwCallDetail vwCallDetail=db.vwCallDetails.Find(id);
if(vwcalldetail==null)
{
返回HttpNotFound();
}
返回视图(vwcalldetail);
}
//
//获取:/CallTrack/Create
公共操作结果创建()
{
返回视图();
}
//
//POST:/CallTrack/Create
[HttpPost]
公共操作结果创建(vwCallDetail vwCallDetail)
{
if(ModelState.IsValid)
{
db.vwCallDetails.Add(vwCallDetails);
db.SaveChanges();
返回操作(“索引”);
}
返回视图(vwcalldetail);
}
//
//获取:/CallTrack/Edit/5
公共操作结果编辑(int id=0)
{
vwCallDetail vwCallDetail=db.vwCallDetails.Find(id);
if(vwcalldetail==null)
{
返回HttpNotFound();
}
返回视图(vwcalldetail);
}
//
//POST:/CallTrack/Edit/5
[HttpPost]
公共操作结果编辑(vwCallDetail vwCallDetail)
{
if(ModelState.IsValid)
{
db.Entry(vwcalldetail).State=EntityState.Modified;
db.SaveChanges();
返回操作(“索引”);
}
返回视图(vwcalldetail);
}
//
//获取:/CallTrack/Delete/5
公共操作结果删除(int id=0)
{
vwCallDetail vwCallDetail=db.vwCallDetails.Find(id);
if(vwcalldetail==null)
{
返回HttpNotFound();
}
返回视图(vwcalldetail);
}
//
//POST:/CallTrack/Delete/5
[HttpPost,ActionName(“删除”)]
公共行动结果删除已确认(内部id)
{
vwCallDetail vwCallDetail=db.vwCallDetails.Find(id);
db.vwCallDetails.Remove(vwCallDetails);
db.SaveChanges();
返回操作(“索引”);
}
受保护的覆盖无效处置(布尔处置)
{
db.Dispose();
基地。处置(处置);
}
}
}
下面是_Layout.cshtml文件

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC4Trial.Models;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;

namespace MVC4Trial.Controllers
{
    public class CallTrackController : Controller
    {
        private CallTrackEntities db = new CallTrackEntities();

        //
        // GET: /CallTrack/

        public ActionResult Index()
        {
            return View(db.vwCallDetails.ToList());
        }


        public ActionResult vwCallDetails([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetCallDetails().ToDataSourceResult(request));
        }

        private static IEnumerable<vwCallDetail> GetCallDetails()
        {
            var callDetails = new CallTrackEntities();
            return callDetails.vwCallDetails.Select(vwCallDetail => new vwCallDetail
            {
                CCCID = vwCallDetail.CCCID,
                Mp3_Url = vwCallDetail.Mp3_Url,
                Index = vwCallDetail.Index,
                Target_Number = vwCallDetail.Target_Number,
                Duration = vwCallDetail.Duration,
                LocalTime = vwCallDetail.LocalTime,
                Site_Name___Address = vwCallDetail.Site_Name___Address,
                Ad_Source_Name = vwCallDetail.Ad_Source_Name,
                Tracking_Number = vwCallDetail.Tracking_Number,
                Caller_Number = vwCallDetail.Caller_Number,
                Available_Feature = vwCallDetail.Available_Feature


            });
        }


        public ActionResult Details(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /CallTrack/Create

        [HttpPost]
        public ActionResult Create(vwCallDetail vwcalldetail)
        {
            if (ModelState.IsValid)
            {
                db.vwCallDetails.Add(vwcalldetail);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Edit/5

        public ActionResult Edit(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // POST: /CallTrack/Edit/5

        [HttpPost]
        public ActionResult Edit(vwCallDetail vwcalldetail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(vwcalldetail).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(vwcalldetail);
        }

        //
        // GET: /CallTrack/Delete/5

        public ActionResult Delete(int id = 0)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            if (vwcalldetail == null)
            {
                return HttpNotFound();
            }
            return View(vwcalldetail);
        }

        //
        // POST: /CallTrack/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            vwCallDetail vwcalldetail = db.vwCallDetails.Find(id);
            db.vwCallDetails.Remove(vwcalldetail);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Kendo UI Sample</title>
         <link rel="stylesheet" href="@Url.Content("~/Content/kendo.common.min.css")">
         <link rel="stylesheet" href="@Url.Content("~/Content/kendo.default.min.css")">
         <script src="@Url.Content("~/Scripts/jquery.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.web.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>
         <link href="@Url.Content("~/Content/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
         <script src="@Url.Content("~/Scripts/kendo.dataviz.min.js")"></script>
         <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>
    </head>
    <body>
        <header>
            <div class="content-wrapper">

                <div class="float-right">
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>

        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

@标题-剑道UI示例