I have a gridview in which I’ve used HTML radio buttons for selecting a particular row. Now these radio buttons need to be enabled only if there is a value in the MAP_ID column.
Below is my gridview columns:
<asp:BoundField DataField="MAp_ID" HeaderText="MAP_ID" ItemStyle-Width="10%"> </asp:BoundField >
<asp:TemplateField HeaderText="Select" ItemStyle-Width="3%>
<ItemTemplate>
<input name="MyRadioButton" class="radioButton" type="radio"
id='<%# Eval("Row_Number") %>' value='<%# Eval("Row_Number") %>'
disabled ='<%# Convert.ToString(Eval("MAP_ID")) != "" ? "" : "disabled" %>' />
</ItemTemplate>
</asp:TemplateField>
Now the problem is even if there is a value in MAP_ID column, all the radio buttons are disabled.
Disabledis not a true/false attribute, if you want to enable or disable a control you’ll need to choose whether thedisabledkeyword exists at all or not.This will work: