【问题标题】:Telerik Grid add, update and delete not workingTelerik Grid 添加、更新和删除不起作用
【发布时间】:2015-03-13 08:34:43
【问题描述】:

我正在使用 mvc c# 和 Html.Telerik().Grid

我想在网格上添加、更新和删除。但它没有发布数据添加、更新和删除功能。

这是我的网格

@(Html.Telerik().Grid<GownHire.Models.tblstudent>()
        .Name("Grid")
        .DataKeys(dataKeys => dataKeys.Add(c => c.PKStudentID))
        .ToolBar(commands => commands.Insert())
        .DataBinding(dataBinding => dataBinding

            .Ajax()                
                .Select("_studentList", "Admin")              
                .Insert("studentInsert", "Admin")                
                .Update("studentUpdate", "Admin")                
                .Delete("studentDelete", "Admin")
        )
        .Columns(columns =>
        {
            columns.Bound(c => c.studentEnterDate);
            columns.Bound(c => c.flage);

            columns.Command(commands =>
            {
                commands.Edit();
                commands.Delete();
            })
                       .Width(180);
        }))

这是 mu 函数

    [GridAction(EnableCustomBinding = true)]
    public ActionResult studentUpdate(GridCommand command, tblstudent model)
  {
    // model data is null
    }

我的代码有什么问题?

【问题讨论】:

  • 您的方法名称在.Ajax() 下说明。控制器类中的方法名称必须与这些名称匹配。
  • 对不起。我忘了在我的问题中更改函数名称。仍然有同样的错误。
  • 您是否通过在方法顶部放置断点来绝对验证您的更新方法不会被调用?
  • 更新方法(studentUpdate)正在调用。但模型数据为空
  • 您在使用 TryUpdateModel 吗?这就是我们对方法进行编码的方式。 weblogs.asp.net/rashid/telerik-asp-net-mvc-grid-preview-take-2

标签: c# asp.net-mvc-3 telerik


【解决方案1】:

user1348351:您的 actionMethod "CeremonyUpdate" 不是您在网格上声明的。将其更改为“_studentList”以选择数据,它将起作用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-30
    • 2012-07-24
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-07
    • 2015-02-02
    相关资源
    最近更新 更多