关闭

GridView 全选

283人阅读 评论(0) 收藏 举报

javascript:

 <script type="text/javascript">
    function CheckAllC(oCheckbox)
     {
       var GridView1 = document.getElementById("<%=GridView1.ClientID %>");
           for(i = 1;i < GridView1.rows.length; i++)
           {
            GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = oCheckbox.checked;
           }
      }
    </script>


.aspx:

 <asp:GridView ID="GridView1" runat="server" Width="80%" AutoGenerateColumns="False" DataKeyNames="aa">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <input id="Checkbox2" runat="server" type="checkbox" onclick="CheckAllC(this)"/>
                        全选
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="ItemCheckBoxC" runat="server" />
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:BoundField DataField="aa" Visible="False" />
                <asp:BoundField DataField="cc" HeaderText="cc" />
                <asp:BoundField DataField="dd" HeaderText="dd" />
                <asp:BoundField DataField="ee" HeaderText="ee" />
            </Columns>
            <RowStyle HorizontalAlign="Center" />
            <AlternatingRowStyle HorizontalAlign="Center" />
            <PagerSettings Visible="False" />
        </asp:GridView>
 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4137次
    • 积分:95
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档