您的位置:首页 > 其它

GridView的全选/取消全选(二)--完美联动版(源码,截图)

2008-07-30 10:40 447 查看
特点:
1.与http://www.126.com/邮箱的效果相当。GridView的行与CheckBox,CheckBox列自身(与列头checkbox)实现联动选择效果。
2.实用行强,界面友好,用户用好。
截图如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dszq.aspx.cs" Inherits="dszq" %>
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml">
5<head runat="server">
6 <title>GridView选择联动版-东山再起-</title>
7</head>
8<body>
9 <form id="form1" runat="server">
10 <div>
11 <asp:GridView ID="mygridview" PageSize="20" runat="server" AutoGenerateColumns="False"
12 BorderWidth="0px" BackColor="#6ba5d8" CellPadding="2" CellSpacing="1" Font-Size="12px"
13 Width="100%" OnRowDataBound="mygridview_RowDataBound" EmptyDataText="暂无信息!">
14 <Columns>
15 <asp:BoundField DataField="A" HeaderText="A" />
16 <asp:BoundField DataField="B" HeaderText="B" />
17 <asp:BoundField DataField="C" HeaderText="C" />
18 <asp:BoundField DataField="D" HeaderText="D" />
19 <asp:TemplateField>
20 <HeaderTemplate>
21 <font face="宋体">
22 <asp:CheckBox ID="CheckBox2" onclick="SelectAll(this);" runat="server"></asp:CheckBox></font>
23 </HeaderTemplate>
24 <ItemTemplate>
25 <asp:CheckBox ID="CheckBox1" Height="100%" runat="server" Width="100%"></asp:CheckBox>
26 </ItemTemplate>
27 <ItemStyle Width="20px" />
28 </asp:TemplateField>
29 </Columns>
30 <RowStyle BackColor="White" Height="20px" HorizontalAlign="Center" VerticalAlign="Middle"
31 Wrap="False" />
32 <EmptyDataRowStyle BackColor="#EFF3FB" HorizontalAlign="Center" Height="20px" />
33 <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
34 <PagerStyle BackColor="#E0E0E0" HorizontalAlign="Right" />
35 <HeaderStyle BackColor="#6699cc" Font-Bold="True" ForeColor="White" Height="22px" />
36 <AlternatingRowStyle BackColor="#EFF3FB" />
37 </asp:GridView>
38 </div>
39 </form>
40</body>
41</html>
42
43<script type="text/javascript">
44 var e;
48 //鼠标移入
49 function mouseOver(row,nowRadio)
50
55 //鼠标移出
56 function mouseOut(row,rowindex,nowRadio)
57
75 function setCheck(row,rowIndex,nowCheckbox) //行,行号,选择框
77
114
115 function IsContact(nowRadio)
116
140
141
142 function SelectAll(tempControl)
144
160</script>
161
162

using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11
12public partial class dszq : System.Web.UI.Page
13
示例下载
声明:本人源码,无私贡献,帮助需要的人。如果转载请注明出处。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: