asp.net DataList 复选框 也玩 全选反选全不选 by shawl.qiu
来源:互联网 发布:淘宝上的铁观音 编辑:程序博客网 时间:2024/05/18 15:51
asp.net DataList 复选框 也玩 全选反选全不选 by shawl.qiu
入乡随俗呀, 既然使用 asp.net 就要使用 asp.net 的模式处理问题...
详细看代码...
shawl.qiu
2007-03-07
http://blog.csdn.net/btbtd
- <%@ Page Language="C#" AutoEventWireup="True" %>
- <%@ import Namespace="System.Data" %>
- <script runat="server">
- void Page_Load(Object s, EventArgs e)
- {
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("id", typeof(int)));
- DataRow dr;
- for(int i=0; i<10; i++)
- {
- dr = dt.NewRow();
- dr[0] = i;
- dt.Rows.Add(dr);
- }
- if(!IsPostBack)
- {
- listAtDataList.DataSource = dt;
- listAtDataList.DataBind();
- }
- } // end Page_Load
- private void SelectAllCbxForDataList(DataList dl, string cbxId)
- {
- for(int i=0, j=dl.Items.Count; i<j; i++)
- {
- CheckBox cbx = (CheckBox)dl.Items[i].FindControl(cbxId);
- cbx.Checked = true;
- }
- } // end private void SelectAllCbxForDataList
- private void UnSelectAllCbxForDataList(DataList dl, string cbxId)
- {
- for(int i=0, j=dl.Items.Count; i<j; i++)
- {
- CheckBox cbx = (CheckBox)dl.Items[i].FindControl(cbxId);
- cbx.Checked = false;
- }
- } // private void UnSelectAllCbxForDataList
- private void SelectReverseCbxForDataList(DataList dl, string cbxId)
- {
- for(int i=0, j=dl.Items.Count; i<j; i++)
- {
- CheckBox cbx = (CheckBox)dl.Items[i].FindControl(cbxId);
- if(cbx.Checked == true)cbx.Checked = false;
- else cbx.Checked = true;
- }
- }
- private void CbxSleForDl(Object s, CommandEventArgs e)
- {
- switch(e.CommandName)
- {
- case "all":
- SelectAllCbxForDataList(listAtDataList, "optCheckBox");
- break;
- case "none":
- UnSelectAllCbxForDataList(listAtDataList, "optCheckBox");
- break;
- case "reverse":
- SelectReverseCbxForDataList(listAtDataList, "optCheckBox");
- break;
- }
- }
- </script>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>shawl.qiu template</title>
- </head>
- <body>
- <form runat="server">
- <div class="cbxSle algr ">
- <asp:Button id=SelectAllButton runat=server
- Text="all"
- CommandName = "all"
- OnCommand = CbxSleForDl
- />
- <asp:Button id=UnSelectAllButton runat=server
- Text="none"
- CommandName = "none"
- OnCommand = CbxSleForDl
- />
- <asp:Button id=SelectReverseButton runat=server
- Text="reverse"
- CommandName = "reverse"
- OnCommand = CbxSleForDl
- />
- </div>
- <br clear="both" />
- <ol>
- <asp:DataList id="listAtDataList"
- BorderColor="black"
- CellPadding="5"
- CellSpacing="5"
- RepeatDirection="Horizontal"
- RepeatLayout="Flow"
- RepeatColumns="10"
- ShowBorder="True"
- runat="server">
- <HeaderTemplate>
- <h3 class="algr">fan for this</h3>
- </HeaderTemplate>
- <HeaderStyle>
- </HeaderStyle>
- <AlternatingItemStyle CssClass="atListAlSty">
- </AlternatingItemStyle>
- <ItemTemplate>
- kkkkkkkkkkk
- <li><asp:CheckBox id=optCheckBox runat=server /></li>
- </ItemTemplate>
- <%--
- <SeparatorTemplate>
- </SeparatorTemplate>
- --%>
- <FooterTemplate>
- </FooterTemplate>
- </asp:DataList>
- </ol>
- </form>
- </body>
- </html>
- asp.net DataList 复选框 也玩 全选反选全不选 by shawl.qiu
- ASP 初阶笔记 By Shawl.qiu
- asp.net 中 使用 ado 的 Recordset GetString 函数 By shawl.qiu
- 7-Zip for Asp.Net by shawl.qiu 2007-10-28
- asp jscript 调用 asp vbscript class/类, by shawl.qiu
- ASP VBScript 动态包含文件, FSO 实现 By Shawl.qiu
- ASP 优化之显示数据查询内容 By shawl.qiu
- ASP + Access 初阶笔记 By Shawl.qiu
- ASP VBScript 函数 之返回多个值 By shawl.qiu
- ASP ADO getRows() 使用演示 By shawl.qiu
- ASP CDO.Message 发送邮件完整实例 By shawl.qiu
- c# .net 上传多个文件 By shawl.qiu
- c# .net 生成缩略图(按比例) By shawl.qiu
- c# .net 生成图片验证码 By shawl.qiu
- sqEditor HTML 编辑器 for .net v1.0 By shawl.qiu
- shawl.qiu c# .net DataList, Repeater, DataGrid 分页类 v1.0
- 关闭Modem拔号音 By Shawl.qiu
- js prototype 格式化数字 By shawl.qiu
- 漫游用户自己的配置文件
- 转 6年测试工作的思考之二
- PHP与MYSQL交互函数表学习笔记
- 由于图片链接问题导致Web性能的严重的下降(转贴)
- Not Comparator's tricks.
- asp.net DataList 复选框 也玩 全选反选全不选 by shawl.qiu
- (回溯算法)商人怎样安全过河
- 在 Windows 上管理类路径的技巧
- 架构师的书籍
- 转 软件评测师考试经验分享
- GDB调试精粹及使用实例
- 网络广告,什么是“露出”,“CPC”,“CPL”,“CPS”,佣金?网络广知识
- 浅悟劳动法之肯德基劳务派遣案
- 在线测试明星脸