Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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
Kendo ui Kendo DropdownlistFor nullable bool未设置null值_Kendo Ui_Nullable_Dropdownlistfor - Fatal编程技术网

Kendo ui Kendo DropdownlistFor nullable bool未设置null值

Kendo ui Kendo DropdownlistFor nullable bool未设置null值,kendo-ui,nullable,dropdownlistfor,Kendo Ui,Nullable,Dropdownlistfor,为什么会发生这种情况?试试选项标签属性,它对我有用 [DisplayName("Autostart Load")] public bool? AutoStartLoad { get; set; } @Html.Kendo().DropDownListFor(model=>model.SomeProperty).OptionLabel(“选择值…”).BindTo(新列表()) { 新建SelectListItem(){Text=“Yes”,Value=“True”}, 新建SelectList

为什么会发生这种情况?

试试
选项标签
属性,它对我有用

[DisplayName("Autostart Load")]
public bool? AutoStartLoad { get; set; }
@Html.Kendo().DropDownListFor(model=>model.SomeProperty).OptionLabel(“选择值…”).BindTo(新列表())
{
新建SelectListItem(){Text=“Yes”,Value=“True”},
新建SelectListItem(){Text=“No”,Value=“False”},
});
公共场所?SomeProperty{get;set;}
同时设置
true
false
值,以大写字母开头,因为
bool.ToString()
将值返回为
“true”
“false”
请尝试以下操作:

@Html.Kendo().DropDownListFor(model => model.SomeProperty).OptionLabel("Choose value...").BindTo(new List<SelectListItem>()
            {
                new SelectListItem() { Text = "Yes", Value = "True" },
                new SelectListItem() { Text = "No", Value = "False" },
            });

public bool? SomeProperty { get; set; }
@Html.Kendo().DropDownListFor(model=>model.SomeProperty).BindTo(新列表()
{
新建SelectListItem(){Text=“Choose value…”,value=“null”},
新建SelectListItem(){Text=“Yes”,Value=“True”},
新建SelectListItem(){Text=“No”,Value=“False”},
});
这不是剑道控制特有的问题。我们有一个类似的问题,自定义3状态选项按钮组。除非将空值作为字符串发布,否则不会发布它们


在原始代码中,只需在引号中加null。这应该可以解决问题。

这是剑道格网吗?你真的测试过吗?“它不仅不起作用,而且当我把真假大写时,它甚至更坏了。”@JohnLord答案是5岁。从那以后可能发生了很多变化。除了bool.ToString()在绑定到模型并且控件呈现现有模型值时仍能很好地利用它之外,它显然没有在内部进行字符串比较。我不知道这是否改变了,但它没有资本化,也没有资本化。很抱歉,我不确定:)我不记得了,但我认为它在过去对我有效
@Html.Kendo().DropDownListFor(model => model.SomeProperty).OptionLabel("Choose value...").BindTo(new List<SelectListItem>()
            {
                new SelectListItem() { Text = "Yes", Value = "True" },
                new SelectListItem() { Text = "No", Value = "False" },
            });

public bool? SomeProperty { get; set; }
@Html.Kendo().DropDownListFor(model => model.SomeProperty).BindTo(new List<SelectListItem>()
        {
    
            new SelectListItem() { Text = "Choose value...", Value = "null" },
            new SelectListItem() { Text = "Yes", Value = "True" },
            new SelectListItem() { Text = "No", Value = "False" },
        });