Asp.net从生成的单选按钮中选择一个

时间:2017-05-17 07:35:07

标签: c# asp.net radio-button

我有下面的代码,组名不起作用, 用户可以从单选按钮

中选择多个
<asp:ListView ID="lstActive" runat="server" OnItemDataBound="lstAllWActive_ItemDataBound">
    <ItemTemplate>

        <tr>
            <td><%# Eval("PollQuestion") %></td>
            <td>
                <asp:HiddenField ID="hdPollId" runat="server" Value='<%#Eval("PollId")%>' />

                <asp:ListView ID="lstOptionWPrecentage" runat="server">
                    <ItemTemplate>
                        <div class='col-md-4'>
                            <asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("Id")%>' />

                            <asp:RadioButton ID="po1" runat="server" GroupName="jhhhh" ValidationGroup="poll" />
                            <label for='po1'><%# Eval("OptionText") %> </label>
                        </div>
                    </ItemTemplate>
                </asp:ListView>


            </td>
            <td><%# Eval("PollName") %>    </td>
        </tr>

    </ItemTemplate>
</asp:ListView>

1 个答案:

答案 0 :(得分:0)

感谢您帮助我按照上述说法做好了

<asp:ListView ID="lstActive" runat="server" OnItemDataBound="lstActive_ItemDataBound" >
      <ItemTemplate>
 <tr>
  <td><%# Eval("PollQuestion") %></td>
     <td> <asp:HiddenField ID="hdPollId" runat="server" 
        Value='<%#Eval("PollId")%>' />
        <div class='col-md-4'>   <asp:RadioButtonList ID="RadioButtonList1" 
           runat="server" DataTextField="OptionText"  DataValueField="Id">
           </asp:RadioButtonList>
        </div>   </td>
       <td><%# Eval("PollName") %>    </td>
                       </tr>
                         </ItemTemplate>
                              </asp:ListView>