Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 验证在剑道网格批处理编辑中不起作用_Asp.net Mvc_Asp.net Mvc 4_Kendo Ui_Kendo Grid_Kendo Asp.net Mvc - Fatal编程技术网

Asp.net mvc 验证在剑道网格批处理编辑中不起作用

Asp.net mvc 验证在剑道网格批处理编辑中不起作用,asp.net-mvc,asp.net-mvc-4,kendo-ui,kendo-grid,kendo-asp.net-mvc,Asp.net Mvc,Asp.net Mvc 4,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,您好,我正在使用剑道下拉菜单作为网格中的编辑器模板,它工作正常,但如果从下拉菜单中未选择任何值,我单击“添加新”,则不会在网格中显示错误并向网格中添加新行。。。我的验证无效 这是我的网格代码: @(Html.Kendo().Grid(Model.PrevilegeViewModels) .Name("PrevilegeViewModels") .ToolBar(tools => tools.Create().Text("Add ne

您好,我正在使用剑道下拉菜单作为网格中的编辑器模板,它工作正常,但如果从下拉菜单中未选择任何值,我单击“添加新”,则不会在网格中显示错误并向网格中添加新行。。。我的验证无效

这是我的网格代码:

 @(Html.Kendo().Grid(Model.PrevilegeViewModels)
              .Name("PrevilegeViewModels")
              .ToolBar(tools => tools.Create().Text("Add new product"))
              .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
              .Columns(columns =>
              {
                  columns.Bound(p => p.Table_ID).ClientTemplate("#= Table_ID #" +
                  "<input type='hidden' name='PrevilegeViewModels[#= index(data)#].Table_ID' value='#= Table_ID #' />"
                  ).EditorTemplateName("Table").Title("Table").Width(300);

                columns.Bound(p => p.P_Add).Title("ADD").ClientTemplate("#= P_Add #" +
                    "<input type='hidden' name='PrevilegeViewModels[#= index(data)#].P_Add' value='#= P_Add #' />"
                  ).Width(150);
                  columns.Bound(p => p.P_Delete).Title("DELETE").ClientTemplate("#= P_Delete #" +
                    "<input type='hidden' name='PrevilegeViewModels[#= index(data)#].P_Delete' value='#= P_Delete #' />"
                  ).Width(150);
                  columns.Bound(p => p.P_Edit).Title("EDIT").ClientTemplate("#= P_Edit #" +
                    "<input type='hidden' name='PrevilegeViewModels[#= index(data)#].P_Edit' value='#= P_Edit #' />"
                  ).Width(150);
                  columns.Command(command => command.Destroy()).Width(100);
              })
              .DataSource(dataSource => dataSource.Ajax()
                   .Model(model =>
                   {
                       model.Id(p => p.Previleges_ID);
                       model.Field(p => p.Previleges_ID).Editable(false);
                   })
                   .ServerOperation(false)
              )
        )
那是我的模型

public class PrevilegeViewModel
    {
        [Key]
        public int Previleges_ID { get; set; }
        [Required]
        [Range(1,UInt32.MaxValue)]
        public int Table_ID { get; set; }
        [Required]
        public bool P_Add { get; set; }
        [Required]
        public bool P_Edit { get; set; }
        [Required]
        public bool P_Delete { get; set; }        
    }
我希望如果我没有在下拉列表中选择任何值,它不会取零,也不会添加新行。。提供验证错误

我还附上了UI图片。请引导我

public class PrevilegeViewModel
    {
        [Key]
        public int Previleges_ID { get; set; }
        [Required]
        [Range(1,UInt32.MaxValue)]
        public int Table_ID { get; set; }
        [Required]
        public bool P_Add { get; set; }
        [Required]
        public bool P_Edit { get; set; }
        [Required]
        public bool P_Delete { get; set; }        
    }