I do have the following HTML
<td>
<input type="checkbox" id="PrevPay" checked="@(item.BSBreakTPayType.Value==322 ? "checked":"")" />
</td>
<td>
<input type="checkbox" id="Fullpay" checked="@(item.BSBreakTPayType.Value==323 ? "checked" : "") "/>
</td>
<td>
<input type="checkbox" id="Halfpay" checked="@(item.BSBreakTPayType.Value==324 ? "checked" : "")" />
</td>
<td>
<input type="checkbox" id="Nopay" checked="@(item.BSBreakTPayType.Value==325 ? "checked" : "")"/>
</td>
Now here I need to display all the checkboxes and need to check only the checkbox which contains a value. The above code check's all the checkboxes. Am I wrong somewhere please correct me. Thanks
You have to put it following way for each checkbox, when checked
attribute is rendered, checkbox gets checked:
<input type="checkbox"
id="PrevPay"
@(item.BSBreakTPayType.Value==322 ? Html.Raw("checked=\"checked\"").ToHtmlString() :"") />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.