zoukankan      html  css  js  c++  java
  • Gridview全选

    1、js代码


    <script language="javascript" type="text/javascript">
            
             
    function chkAll(controlid, chkboxAllID)
            {
               
    var chkall = document.getElementById(chkboxAllID);
               
               
    var chkother = document.getElementsByTagName("input");
               
               
    for (var i = 0; i < chkother.length; i ++ )
               {
                  
    if( chkother[i].type == 'checkbox')
                  {
                     
    if(chkother[i].id.indexOf(controlid) > - 1)
                     {
                        
    if(chkall.checked == true)
                        {
                           chkother[i].checked 
    = true;
                        }
                        
    else
                        {
                           chkother[i].checked 
    = false;
                        }
                     }
                  }
               }
            }


        
    </script>

    2 、控件代码


    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                        ForeColor
    ="#333333" GridLines="None" PageSize="8" Width="800px" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                        OnRowDataBound
    ="GridView1_RowDataBound" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
                        
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <Columns>
                            
    <asp:TemplateField HeaderText="全选">
                                
    <ItemTemplate>
                                    
    <asp:CheckBox ID="Check" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                    
    <asp:CheckBox ID="CheckBoxAll" runat="server" Text="全选" onclick="chkAll('GridView1', this.id)" />
                                </HeaderTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="编号">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("User_ID") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="用户ID">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label2" runat="server" Text='<%# Eval("User_Name") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="用户名">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label3" runat="server" Text='<%# Eval("User_RellName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="公司名">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label5" runat="server" Text='<%# Eval("user_companyName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="User_RegTime" DataFormatString="{0:d}" HeaderText="注册时间"
                                HtmlEncode
    ="False" ReadOnly="True" />
                            <asp:TemplateField HeaderText="是否通过审核">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label4" runat="server" Text='<%#MadeStr(Eval("User_Check"))%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="等级">
                                
    <ItemTemplate>
                                    
    <asp:Label ID="Label6" runat="server" Text='<%# FormatUserlevel(Eval("User_UserLevel"))%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    
    <asp:DropDownList ID="ddl_userLevel" runat="server">
                                    
    </asp:DropDownList>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="推荐度" DataField="User_tuijiandu" />
                            <asp:TemplateField HeaderText="查看">
                                
    <ItemTemplate>
                                    
    <a href="UserInfo.aspx?userid=<%#Eval("User_ID") %>">查看</a>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowEditButton="True" HeaderText="修改" />
                        </Columns>
                        <RowStyle BackColor="#EFF3FB" />
                        <EditRowStyle BackColor="#2461BF" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
  • 相关阅读:
    PHP生成xml 无法识别或是无法读取或是浏览器不识别等问题
    关于PHP 采集类
    Centos7 下安装Docke
    Git使用之设置SSH Key
    yii2.0中Rbac 怎么添加超加管理员
    Undefined index: HTTP_RAW_POST_DATA的解决办法
    window下phpstudy的nginx配置虚拟主机
    yii2.0中添加二维数组,多条数据。
    预防onion比特币勒索病毒,如何快速关闭135,137,138,139,445端口
    github与git之间怎么建立连接
  • 原文地址:https://www.cnblogs.com/lyl6796910/p/3746634.html
Copyright © 2011-2022 走看看