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的变态位运算 var a = "10" | 0; alert(a); alert (typeof a);结果为10,number. 这就是说这条语句可以将字符串 ...
- LeetCode Database: Consecutive Numbers
Consecutive Numbers Write a SQL query to find all numbers that appear at least three times consecuti ...
- 想要完全导入swc中的所有类
其实还有个这个办法.修改参数.-include-libraries library [...] 强制导入SWC文件中的所有类,不管是否曾使用过这个类 (((比如把swc文件放到src里,然后编译参数加 ...
- cocos 自适应屏幕分辨率
提供了三种适配策略:kResolutionNoBorder:超出屏幕的部分会被裁剪,两侧没有黑边,铺满屏幕,按图片原始比例显示,图片不变形.kResolutionShowAll:整个游戏界面是可见的, ...
- dom 优酷得弹出
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- OperateParticleWithCodes
[OperateParticleWithCodes] Listing 6-6 shows how you might configure an emitter’s scale property. Th ...
- class int
class int(object): """ int(x=0) -> integer int(x, base=10) -> integer Convert a ...
- winform 映射字段的写法:
public partial class FrmFieldMapping : DevComponents.DotNetBar.Office2007Form { private AMDataFieldC ...
- hdoj 5349 MZL's simple problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5349 #include<stdio.h> int main(){ int cnt; int ...
- Python之函数进阶
本节内容 上一篇中介绍了Python中函数的定义.函数的调用.函数的参数以及变量的作用域等内容,现在来说下函数的一些高级特性: 递归函数 嵌套函数与闭包 匿名函数 高阶函数 内置函数 总结 一.递归函 ...