Basically, I want my switches to be checked depending on the value from my model view control, below is an example of the code and my attempt:
<tr>
<td>
<label for="brakepads" class="label3">Brake Pads:</label></td>
<%= Html.TextBox("brakepads", Model.brakepads, new {style="display:none" })%>
<%= Html.ValidationMessage("brakepads", "*") %>
<td><label for="brakefluid" class="label4" >Passed:</label>
<asp:RadioButton ID="RadioButton15" runat="server" GroupName="b" value="True" Checked="<%= Model.brakepads.Value %>" onclick="brakepads.value=(this.value)" /></td>
<td><label for="brakefluid" class="label4" >Failed:</label>
<asp:RadioButton ID="RadioButton16" runat="server" GroupName="b" value="False" Checked="<% Model.brakepads.Value %>" onclick="brakepads.value=(this.value)"/></td>
</tr>
I get the following at runtime: I cannot create an object of type "System.Boolean" from its string representation "<% = Model.brakepads.Value%>" for the property "Checked".
I tried using (bool) for casting, but that didn't work either, so I'm not sure what to do next. My only problem is that sometimes the bool will be null, if this does not break the functionality, then this is normal.
source
share