• 怎樣添加設置GridView,CheckBox全選功能


    GridView內CheckBox控件全選設置

    不需要添加後台代碼操作,前端即可完成設置,如下:

    前端代碼:

    1.設置javascript。

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <script type="text/javascript">

    function CheckAll3(oCheckbox)
    {
    var GridView3 = document.getElementById("<%=GridView1.ClientID %>");
    for(var i = 1; i < GridView1.rows.length; i++)
    {
    GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = oCheckbox.checked;
    }

    }
    </script>

    2.body內代碼:

    <asp:GridView ID="GridView1" runat="server" Height="2px" Width="720px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting" AutoGenerateColumns="False" PageSize="8" >
    <RowStyle ForeColor="#000066" />
    <FooterStyle BackColor="White" ForeColor="#000066" />

    <Columns>

    <asp:TemplateField>
    <ItemTemplate>
    <asp:CheckBox ID="CheckBox1" runat="server" />
    <asp:Label ID="lbuid" runat="server" Visible="false" Text='<%# Eval("data") %>'></asp:Label>
    </ItemTemplate>
    <HeaderTemplate>
    <input type="checkbox" id="ChkHead" onclick="CheckAll3(this)" title="選擇全部" />
    <%--<asp:CheckBox ID="CheckBoxALL" runat="server" AutoPostBack="True" />--%>
    </HeaderTemplate>
    <HeaderStyle Width="20px" />
    <ItemStyle Width="20px" />

    </asp:TemplateField>
                                <asp:BoundField DataField="data" HeaderText="日期(data)" ReadOnly="True" />
                                <asp:BoundField DataField="users" HeaderText="姓名(users)" SortExpression="姓名" />
                                <asp:BoundField DataField="user_name" HeaderText="賬號(user_name)"  />
                                <asp:BoundField DataField="user_email" HeaderText="郵箱(user_email)"  />
                                <asp:BoundField DataField="mony" HeaderText="金額(mony)" />

                 </Columns>
    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing" />


    </asp:GridView>

  • 相关阅读:
    使用socket BPF/Linux内核工程导论——网络:Filter(LSF、BPF、eBPF)
    使用Iperf工具测试android系统网络wifi的吞吐量wifithrougput
    html input中 button和submit的区别
    Linux转发性能评估与优化(转发瓶颈分析与解决方案)
    交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别
    MySQL查询不区分大小写的sql写法
    Docker镜像保存save、加载load
    将Spring-boot应用部署到Docker容器
    Docker 安装使用
    Scalatra文件下载时中文乱码
  • 原文地址:https://www.cnblogs.com/popo1/p/10018600.html
Copyright © 2020-2023  润新知