Gargi Narain
Gargi Narain

Reputation: 117

html radio button in Gridview. enable/disble on a column's value

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.

Upvotes: 0

Views: 1140

Answers (1)

Blachshma
Blachshma

Reputation: 17385

Disabled is not a true/false attribute, if you want to enable or disable a control you'll need to choose whether the disabled keyword exists at all or not.

This will work:

<input name="MyRadioButton" class="radioButton" type="radio" id='<%# Eval("MAP_ID") %>' value='<%# Eval("MAP_ID") %>'  <%# Convert.ToString(Eval("MAP_ID")) != "" ? "" : "disabled"  %>  />

Upvotes: 1

Related Questions