How can i get Boolean value or the true or false from controller to a Checkbox in View using this:
@Html.CheckBox("condition", @ViewData["Condition"])
or
<input type = "checkbox" checked = "**true or false?**">
I have this in my Controller..
public ActionResult Member(string sortOrder, string filter, string searchString, int? page, **bool? condition = false**)
and in my view is like this
please help me for this...
@Html.CheckBox("condition")And the parameter needs to bebool condition(notnullable). If the value ofconditionis true, the checkbox will display as checked, otherwise it will be unchecked. But I recommend you use a view model and pass it to the view so you can use the strongly typed HtmlHelper -@Html.CheckBoxFor(m => m.Condition)checkedis bool attribute. It's mere existence ensures the input is checked. So you don't want tochecked=anythingif false because it shouldn't be there i.e. a non checked checkbox would be<input type="checkbox" />whereas<input type="checkbox" checked="false"/>will tick the box as will<input type="checkbox" checked="anything-you-like"/>If thecheckedattribute exists, it will be checked regardless of the value.