zoukankan      html  css  js  c++  java
  • GridView和CheckBox连用,实现全选

     <Columns>
               <asp:TemplateField HeaderText="全选">
               <ItemTemplate>
               <asp:CheckBox ID="cb" runat ="server" />
               </ItemTemplate>
               <HeaderTemplate>
                <asp:CheckBox ID="quanxuan" runat="server" Text="全选" OnCheckedChanged="quanxuan_CheckedChanged" AutoPostBack="true"/>
               </HeaderTemplate>
               </asp:TemplateField>

    --cs文件

     protected void quanxuan_CheckedChanged(object sender, EventArgs e)
        {

            foreach (GridViewRow gr in GridView1.Rows)
            {
                CheckBox cb = gr.FindControl("cb") as CheckBox;
                if (cb.Checked == false)
                {
                    cb.Checked = true;
                }
                else
                {
                    cb.Checked = false;
                }
            }

        }

  • 相关阅读:
    P3383 【模板】线性筛素数
    POJ2431-Expedition【优先队列+贪心】
    HDU1087
    HDU1029
    最小生成树之Kruskal算法
    AC自动机模板
    328闯关解析
    php可获取客户端信息
    $( ).focus()与$( )[0].focus()区别
    RegExp类型和text()方法
  • 原文地址:https://www.cnblogs.com/huanhuan86/p/2364762.html
Copyright © 2011-2022 走看看