I have a Table containing some information that I need. All these rows also contains a column with a radio button in it so that the user is suppose to be able to check one of the rows as default.
When I'm bringing the data back from the DB and want to select the one that's currentlly the default one.
<% foreach (var item in (IEnumerable<Locale>) ViewData["Locales"]) { %>
<tr>
<td>
<%= Html.Encode(item.Language.Name) %>
</td>
<td>
<input type="radio" id="defaultLocale" name="defaultLocele" value="on" checked="<%= item.Default == false ? "false" : "true" %>" />
</td>
I've also tried to do this:
<input type="radio" id="defaultLocale" name="defaultLocele" value="on" checked="<%=item.Default == false ? "" : "checked" %>" />
but nothing seems to do the right thing. I always end up with having the last row in checked, which it isn't for sure.