相关疑难解决方法(0)

Telerik MVC Grid - 可以为空的DateTime属性的问题

我是Telerik MVC扩展的新手.我已成功在视图中实现了我的第一个实例.我没有使用Telerik MVC Grid实现我的第二个视图,但是绑定到网格的类有2列Nullable类型.当我运行我的代码时,视图会发出错误,如下所示:

传递到字典中的模型项为null,但此字典需要"System.DateTime"类型的非null模型项.

我原本以为这可能是一个渲染问题,模板只适用于DateTime而不是Nullable,但后来我完全取出了显示这些DataTime的任何列?属性.

我的代码如下:

查看Telerik MVC Grid的代码

<%= Html.Telerik().Grid(Model.ScheduledCourseList)
.Name("ScheduledCoursesGrid")
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0" }))
.DataKeys(keys => keys.Add(sc => sc.Id))
.DataBinding(dataBinding =>
    dataBinding.Ajax()
        .Select("_List", "Course")
        .Insert("_InsertAjax", "Course")
        .Update("_UpdateAjax", "Course")
        .Delete("_DeleteAjax", "Course")
)
.Columns(columns =>
{
    columns.Bound(c => c.Id).Width(20);
    //columns.Bound(c => c.ScheduledDateTime).Width(120);
    //columns.Bound(c => c.Location).Width(150);
    columns.Command(commands =>
    {
        commands.Edit().ButtonType(GridButtonType.Image);
        commands.Delete().ButtonType(GridButtonType.Image);
    }).Width(180).Title("Commands");
})
.Editable(editing => editing.Mode(GridEditMode.PopUp))
.Sortable()
.Footer(true) %>
Run Code Online (Sandbox Code Playgroud)

DTO

    public class ScheduledCourseDTO
{
    public int Id { get; set; }
    public int CourseId { get; …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc telerik-mvc

3
推荐指数
1
解决办法
6939
查看次数

标签 统计

asp.net-mvc ×1

telerik-mvc ×1