Gridview源代码
- <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
- CaptionAlign="Left" CssClass="FONT1"
- onrowdatabound="GridView1_RowDataBound"
- onrowcommand="GridView1_RowCommand">
- <Columns>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:CheckBox ID="ckb_Sel" runat="server" Enabled="true"/>
- </ItemTemplate>
- <HeaderTemplate>
- <asp:CheckBox ID="ckb_All" runat="server" Enabled="true" οnclick="javascript:Check();" />
- </HeaderTemplate>
- <HeaderStyle HorizontalAlign="Center" Width="15px" />
- <ItemStyle HorizontalAlign="Center" Width="15px" />
- </asp:TemplateField>
- <asp:BoundField HeaderText="No.">
- <HeaderStyle HorizontalAlign="Center" Width="30px" />
- <ItemStyle HorizontalAlign="Center" Width="30px" />
- </asp:BoundField>
- <asp:BoundField DataField="FileName" HeaderText="文件名称">
- <HeaderStyle HorizontalAlign="Center" Width="300px" />
- <ItemStyle HorizontalAlign="Left" Width="300px" />
- </asp:BoundField>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:Button ID="Button1" runat="server" Text="下载" CssClass="FONT1" CommandName="Download" />
- </ItemTemplate>
- <HeaderStyle HorizontalAlign="Center" Width="70px" />
- <ItemStyle HorizontalAlign="Center" Width="70px" />
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
Javascript源代码
- <script language="javascript" type="text/javascript">
- function Check(){
- var checkboxis =GridView1.getElementsByTagName("input");
- var checkall = document.getElementById("GridView1__ctl1_ckb_All");
- for (var i=0; i<checkboxis.length; i++){
- if(checkboxis[i].disabled== checkall.disabled){
- checkboxis[i].checked = checkall.checked;
- }
- }
- }
- </script>