Set checked attribute in Web Forms

1.1k Views Asked by At

I try to set checked attribute for <input type="checkbox"/>:

checked="<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsOperationPerformed")) ? "checked" : string.Empty%>"

But I get an error

Argument type ‘string’ is not assignable to parameter type ‘bool’

IsOperationPerformed of type Boolean.

How can I add cheched attribute?

1

There are 1 best solutions below

5
On BEST ANSWER

As per my knowledge, CheckBox should be equal to either true or false and not checked or empty. Try changing it and revert if problem still occurs. Hope i helped.

checked="<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsOperationPerformed")) ? TRUE : FALSE%>"