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>
Gridview全选的更多相关文章
- 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能
度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...
- DEV控件中GridView中的复选框与CheckBox实现联动的全选功能
最初的界面图如图1-1(全选框ID: cb_checkall DEV控件名称:gcCon ): 要实现的功能如下图(1-2 1-3 1-4)及代码所示: 图1-2 图1-3 图1-4 O(∩_∩ ...
- GridView中实现CheckBox的全选
GridView中实现CheckBox的全选 用服务器端的方法: 在页面上放一个gridview控件,配置好数据源,编辑列, <asp:GridView ID="GridView1&q ...
- GridView CheckBox 全选
GridView CheckBox 全选 <script type="text/javascript"> $(function () { $("#allChe ...
- GridView 用 checkbox 全选并取值
方法一,用 js 实现 <script type="text/javascript"> //<![CDATA[ function CheckAll(oCheckb ...
- asp gridview批量删除和全选
本人新手刚学asp.net 全选和删除也是引用了他人的代码试了一试可以实现,感觉很好,就发了上来. 前台代码 <asp:GridView ID="GridView1" r ...
- gridview checkbox从服务器端和客户端两个方面实现全选和反选
GridView中的checkbox的全选和反选在很多的地方都是要求实现的,所以下面就从服务器端和客户端两个方面实现了checkbox的选择,感兴趣的朋友可以了解下,希望本文对你有所帮助 GridVi ...
- 在GridView中实现全选反选的例子
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridView控件.asp ...
- jquery控制动态生成的gridview中多列checkbox的全选反选及自动判断是否全选状态
动态生成的Gridview的前台html代码如下: <table class="usertableborder" cellspacing="0" ...
随机推荐
- javascript --- 面向对象 --- 封装
javascript中有原型对象和实例对象 如有疑问请参考:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_enca ...
- Chapter12&Chapter13:程序实例
文本查询程序 要求:程序允许用户在一个给定文件中查询单词.查询结果是单词在文件中出现的次数及所在行的列表.如果一个单词在一行中出现多次,此行只列出一次. 对要求的分析: 1.读入文件,必须记住单词出现 ...
- Python 统计文本中单词的个数
1.读文件,通过正则匹配 def statisticWord(): line_number = 0 words_dict = {} with open (r'D:\test\test.txt',enc ...
- PHP强大的内置filter (一)
<?php #PHP内置的validate filter $input_data = True; $result = filter_var($input_data,FILTER_VALIDATE ...
- PHP获取本周开始时间
/*先设置时区*/date_default_timezone_set('PRC');/*网上的写法:总觉得这周跨年或者跨月的时候会悲剧 未验证*/echo mktime(0,0,0,date('m') ...
- 从Mac的Finder中访问你的iCloud文档
[从Mac的Finder中访问你的iCloud文档] 从OS X 10.7.2开始,iCloud就深入Mac当中,我们也可以在Finder中访问储存在iCloud中的文件,甚至当你拥有多台Mac的时候 ...
- 安装php5.5
安装php5.5 ./configure --prefix=/usr/local/php5.5.14/ --with-apxs2=/usr/local/apache2.2.27/bin/apxs -- ...
- LightOJ 13361336 - Sigma Function (找规律 + 唯一分解定理)
http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS Memory L ...
- 研究QGIS二次开发笔记(一)
为了在QT程序中嵌入一个地图,最终选择了QGIS来干这件事.选型阶段真是呵呵.我折腾的是QGIS2.4.0. 首先,到官方网站下载安装QGIS.如果你跟我一样懒的话,可能希望下载一个已经编译好的win ...
- .net 配置ueditor
添加引用如下: <script src="../Ueditor/ueditor.config.js" type="text/javascript"> ...