zoukankan      html  css  js  c++  java
  • js控制Gridview中的checkbox全选(转) 子曰

    js代码部分

    function SelectAll(chkbox)
               {
                  var theBox=chkbox;
                  xState=theBox.checked;   
                  elem=theBox.form.elements;
                  for(i=0;i<elem.length;i++)
                  if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
                   {
                        if(elem[i].checked!=xState)
                           elem[i].click();
                          
                   }
              }

    .net代码部分

    <asp:TemplateField>
                              <HeaderTemplate>
                                <input id="chkHeader" onclick="SelectAll(this)" type="checkbox" />
                              </HeaderTemplate>
                                <ItemTemplate>
                                    <input id="chkItem" type="checkbox" name="chkItem" runat="server" value='<%#Eval("UserID") %>' />
                                </ItemTemplate>
    </asp:TemplateField>                         

    获取选中的checkbox的值

           string str = "";
            for (int i = 0; i < this.GridViewUser.Rows.Count; i++)
            {
                HtmlInputCheckBox chk = (HtmlInputCheckBox)this.GridViewUser.Rows[i].FindControl("chkItem");
                if (chk.Checked == true)
                {
                    str += chk.Value+",";
                }
            }

  • 相关阅读:
    @Controller @RestController
    HOMEWORD2
    cudnn、cuda
    jupyter使用
    python学习——os模块
    python学习——导入模块、__name__
    python学习——文件
    python学习——函数、内置函数
    python学习——for循环的应用
    python学习——字典、集合、数据类型总结
  • 原文地址:https://www.cnblogs.com/suixufeng/p/3336159.html
Copyright © 2011-2022 走看看