mardi 18 septembre 2018

Set checkbox to checked if value is true (.ascx)

I have a problem which I can't solve.

I have a table that fills dynamically with data pulled in from DB. I send it through controller and then access it with . For a cleaner look I decided to show the Boolean value as a checkbox. If true the checkbox should be checked otherwise unchecked.

This code has an error. The error is: "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"

I don't think PHP would have a problem with this but C# does. But no matter how I turn the code around I can't seem to find a way I could set checked value to a checkbox with the help of value I pull in.

 <input type="checkbox" name="checkBoxName" checked="<% ( == true ? "checked" : "") %> />

Also worth mentioning if I do something like the code below the data I pull in is correctly displayed so the issue is not in retrieving the data.

<td>
 <p></p>
</td>

I found Checkbox checked if boolean is true with Angular2 and it didn't work/help.




Aucun commentaire:

Enregistrer un commentaire