GridView无刷新实现全选

Gridview源代码
  1. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
  2.                         CaptionAlign="Left" CssClass="FONT1" 
  3.                         onrowdatabound="GridView1_RowDataBound" 
  4.                         onrowcommand="GridView1_RowCommand">
  5.                         <Columns>
  6.                             <asp:TemplateField>
  7.                                 <ItemTemplate>
  8.                                     <asp:CheckBox ID="ckb_Sel" runat="server" Enabled="true"/>
  9.                                     
  10.                                 </ItemTemplate>
  11.                                 <HeaderTemplate>
  12.                                     <asp:CheckBox ID="ckb_All" runat="server" Enabled="true"  οnclick="javascript:Check();" />
  13.                                 </HeaderTemplate>
  14.                                 <HeaderStyle HorizontalAlign="Center" Width="15px" />
  15.                                 <ItemStyle HorizontalAlign="Center" Width="15px" />
  16.                             </asp:TemplateField>
  17.                             <asp:BoundField HeaderText="No.">
  18.                                 <HeaderStyle HorizontalAlign="Center" Width="30px" />
  19.                                 <ItemStyle HorizontalAlign="Center" Width="30px" />
  20.                             </asp:BoundField>
  21.                             <asp:BoundField DataField="FileName" HeaderText="文件名称">
  22.                                 <HeaderStyle HorizontalAlign="Center" Width="300px" />
  23.                                 <ItemStyle HorizontalAlign="Left" Width="300px" />
  24.                             </asp:BoundField>
  25.                             <asp:TemplateField>
  26.                                 <ItemTemplate>
  27.                                     <asp:Button ID="Button1" runat="server" Text="下载" CssClass="FONT1" CommandName="Download" />
  28.                                 </ItemTemplate>
  29.                                 <HeaderStyle HorizontalAlign="Center" Width="70px" />
  30.                                 <ItemStyle HorizontalAlign="Center" Width="70px" />
  31.                             </asp:TemplateField>
  32.                         </Columns>
  33.                     </asp:GridView>

Javascript源代码

  1. <script language="javascript" type="text/javascript">
  2.     function Check(){
  3.         var checkboxis =GridView1.getElementsByTagName("input");
  4. var checkall = document.getElementById("GridView1__ctl1_ckb_All");
  5. for (var i=0; i<checkboxis.length; i++){
  6.     
  7.     if(checkboxis[i].disabled== checkall.disabled){
  8.     
  9.     checkboxis[i].checked = checkall.checked;
  10.     }
  11. }
  12.     }
  13. </script>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值