0

我有一个gridview使用 HTML 单选按钮来选择特定行的方法。现在,仅当列中有值时才需要启用这些单选按钮MAP_ID

下面是我的gridview列:

<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>

现在的问题是即使MAP_ID列中有值,所有单选按钮都被禁用。

4

1 回答 1

1

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"  %>  />
于 2013-01-14T11:54:06.130 回答