【发布时间】:2014-11-28 21:36:55
【问题描述】:
我尝试为<input type="checkbox"/> 设置checked 属性:
checked="<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsOperationPerformed")) ? "checked" : string.Empty%>"
但我得到一个错误
参数类型“字符串”不能分配给参数类型“布尔”
IsOperationPerformed 类型为 Boolean。
如何添加cheched 属性?
【问题讨论】:
-
您收到错误“IsOperationPerformed of type Boolean.”是什么意思?您收到的确切错误消息是什么。
-
你可以尝试用单引号包裹属性,因为你可以看到这里的引号没有正确转义。
-
@BenRobinson,没有。我说 IsOperationPerformed 的类型为 bool,而我在这种转换中遇到错误
-
好的,你遇到了什么错误?
-
确保
IsOperationPerformed不为 NULL。
标签: c# asp.net checkbox webforms checked