zoukankan      html  css  js  c++  java
  • [转]Gridview中实现RadioButton单选效果

    HTML

    <asp:TemplateField ItemStyle-Width="22px">
                               <ItemTemplate>
                                   <asp:RadioButton ID="radButtonControl" GroupName="group1" runat="server" />
                               </ItemTemplate>
                           </asp:TemplateField>

    CS

    protected void gvWorkPlanList_RowDataBound(object sender, GridViewRowEventArgs e)
           {
               if (e.Row.RowType == DataControlRowType.DataRow)
               {
                   RadioButton rb = (RadioButton)e.Row.FindControl("radButtonControl");
                   if (rb != null)
                       rb.Attributes.Add("onclick", "onRadiobuttonClick('" + this.gvWorkPlanList.ClientID + "','" + rb.ClientID + "')");  
               }
           }

    JS

    /**//*
    传入的GridviewClientID和所选的RadioButton ClientID
    **/
      function onRadiobuttonClick(gvControlID,selectedControlId)
      {
           var inputs = document.getElementById(gvControlID).getElementsByTagName("input");
           for(var i=0; i <inputs.length; i++)
           {
               if(inputs[i].type=="radio")
               {
                   if(inputs[i].id==selectedControlId)
                       inputs[i].checked = true;
                   else
                       inputs[i].checked = false;
                  
               }
           }
      }
  • 相关阅读:
    图片音乐 上传、下载
    表格类型数据,Excel csv导入,导出操作
    逐行读取txt文件,分割,写入txt。。。上传,下载
    性能分析四
    性能分析三
    postman断言
    postman+Newman语法参数
    shell_03
    shell_02
    shell_01
  • 原文地址:https://www.cnblogs.com/bluewhale84/p/4074151.html
Copyright © 2011-2022 走看看