客户端实现全选
 <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="客户端全选.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>WebForm1</title>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="C#" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  <script language="javascript">
  <!--
      function selectAll()
      {
          for(var i=0;i<document.all.length;i++)
          {
             var e=document.all[i];
             if(e.id != "chkSelectAll")
             {
                e.checked=document.all.chkSelectAll.checked;
                if(document.all.chkSelectAll.checked)
                {
     var text = document.getElementById("txt");
     text.value="取消";
    }
    else
    {
     var text = document.getElementById("txt");
     text.value="全选";
    }
             }
            
               
          }
        
      }
  //-->
  </script>
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <asp:DataGrid ID="myGrid" Runat="server" AutoGenerateColumns="False">
    <Columns>
     <asp:TemplateColumn>
      <HeaderTemplate>
       <INPUT id="chkSelectAll" onclick="selectAll()" type="checkbox" name="chkSelectAll"><INPUT id="txt" name="txt" value="全选" style="WIDTH: 42px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 18px; BORDER-BOTTOM-STYLE: none"
        type="text" size="1">
      </HeaderTemplate>
      <ItemTemplate>
       <asp:CheckBox id="chkSelect" Runat="server"></asp:CheckBox><%#DataBinder.Eval(Container.DataItem,"voteItem")%>
      </ItemTemplate>
     </asp:TemplateColumn>
    </Columns>
   </asp:DataGrid></form>
 </body>
</HTML>
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

客户端实现全选

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭