zoukankan      html  css  js  c++  java
  • RadioButton在数据列表中实现单选功能

    在服务器端动态生成的name总是不断变化,故需手动实现单选 ;

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head runat="server">
     3     <title></title>
     4     <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
     5     <script type="text/javascript">
     6         function SinggleSelect(ob) {
     7             $("#<%=dglist.ClientID %>").find("input[type='radio']").each(function () {
     8                 $(this).attr("checked", false); 
     9             });
    10             $(ob).attr("checked", true);
    11         };
    12     </script>
    13 </head>
    14 <body>
    15     <form id="form1" runat="server">
    16     <div>
    17         <asp:GridView ID="dglist" runat="server" >
    18             <Columns>
    19                 <asp:BoundField DataField="Name" HeaderText="名字"  />
    20                 <asp:BoundField DataField="Age" HeaderText="年龄"  />
    21                 <asp:BoundField DataField="Sex" HeaderText="性别"  />
    22                 <asp:TemplateField HeaderText="选择">                     
    23                         <ItemTemplate>
    24                             <asp:RadioButton ID="rbSelect" onclick="SinggleSelect(this)" runat="server" />
    25                         </Itemtemplate>
    26                 </asp:TemplateField>
    27             </Columns>
    28            
    29         </asp:GridView>
    30     </div>
    31     </form>
    32 </body>
    33 </html>
    View Code
  • 相关阅读:
    【C-数据类型 常量 变量】
    【OC简介-类和对象】
    【ios面试总结】
    【OC基础语法考试】
    【C-01关键字】
    UI3
    ui2
    UI
    C++使用shell命令
    字典
  • 原文地址:https://www.cnblogs.com/huangzhen22/p/3258264.html
Copyright © 2011-2022 走看看