1. /// <summary>
  2. /// CheckBoxList數據源
  3. /// 塗聚文
  4. /// 20130705
  5. ///
  6. /// </summary>
  7. private void setCheckBoxList()
  8. {
  9. DataTable dt = new DataTable();
  10. CheckBoxList1.Items.Clear();
  11. dt = geovindu_branchBLL.SelectGeovindu_branchNameDt();
  12. CheckBoxList1.DataSource = dt;
  13. this.CheckBoxList1.DataTextField = "B_Name";
  14. this.CheckBoxList1.DataValueField = "B_EnglishName";
  15. CheckBoxList1.DataBind();
  16.  
  17. }
  18.  
  19. /// <summary>
  20. ///
  21. /// </summary>
  22. /// <param name="sender"></param>
  23. /// <param name="e"></param>
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. if (!IsPostBack)
  27. {
  28. setCheckBoxList();
  29. }
  30.  
  31. }
  32. /// <summary>
  33. /// 獲取選擇的項目
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="e"></param>
  37. protected void Button1_Click(object sender, EventArgs e)
  38. {
  39. string variable = string.Empty;
  40. int i = 0;
  41. foreach (System.Web.UI.WebControls.ListItem oItem in CheckBoxList1.Items)
  42. {
  43. if (oItem.Selected) // if you want only selected
  44. {
  45. if (i ==0)
  46. {
  47. variable = oItem.Value;
  48. }
  49. else
  50. {
  51. variable = variable + "," + oItem.Value;
  52. }
  53. i++;
  54. }
  55. // otherwise get for all items
  56. //variable = oItem.Value;
  57.  
  58. }
  59.  
  60. //傳值給父頁面
  61. this.Page.Controls.Add(new LiteralControl(string.Format("<script>opener.document.form1.txtShoppingDealsBranch.value='{0}'</script>", variable)));
  62.  
  63. //關閉此視窗
  64. this.Page.Controls.Add(new LiteralControl("<script>window.close();</script>"));
  1. <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal" AppendDataBoundItems="True" DataTextField="B_Name" DataValueField="B_EnglishName" RepeatColumns="6" CellPadding="5"
  2. CellSpacing="5" RepeatLayout="Table" BorderStyle="Outset" CssClass="geovindu">
  3. </asp:CheckBoxList><br />
  4. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="確定" /></div>
  1. <style type="text/css">
  2.  
  3. .geovindu INPUT
  4. {
  5. color:black;
  6. border-style: none;
  7. font-family: Tahoma;
  8. font-size: 7px;
  9. margin-right: 5px
  10. }
  11.  
  12. .geovindu td
  13. {
  14. /* font-size:x-large;*/
  15. width:300px;
  16.  
  17. }
  18.  
  19. </style>

Csharp:asp.net CheckBoxList databind的更多相关文章

  1. ASP.NET CheckBoxList Operations with jQuery

    本文描述了如何通过jQuery来对ASP.NET CheckBoxList控件进行一些基本操作,如通过value/text/index check/uncheck CheckBoxList,最小/最大 ...

  2. 适当使用enum做数据字典 ( .net c# winform csharp asp.net webform )

    在一些应用中,通常会用到很多由一些常量来进行描述的状态数据,比如性别(男.女),审核(未审核.已审核)等.在数据库中一般用数字形式来存储,比如0.1等. 不好的做法 经常看到一些应用(ps:最近又看到 ...

  3. ASP.NET CheckBoxList 控件实现全选、反选、清除功能 利用js

    直接看代码: JS代码如下: <script type="text/javascript" language="javascript"> funct ...

  4. csharp:ASP.NET SignalR

    http://signalr.net/ https://github.com/SignalR/SignalR http://www.asp.net/signalr http://www.cnblogs ...

  5. csharp:asp.net Importing or Exporting Data from Worksheets using aspose cell

    using System; using System.Data; using System.Configuration; using System.Collections; using System. ...

  6. C#.NET 通用控件数据源绑定类

    using System.Data; using System.Collections; using System.Collections.Generic; using System.Web.UI; ...

  7. .NET Web开发总结(五)

    7 常用服务器控件 7.1 服务器控件概述 · 服务器控件是指在服务器上执行程序的代码的组件 通常这些服务器控件会提供    给用户一定的界面,  以便用户与服务器之间快速的交互 7.2 HTML 服 ...

  8. Repeater控件实现数据绑定,并实现分页效果

    前台显示代码 <pre name="code" class="csharp"><asp:Repeater ID="Repeater1 ...

  9. LINQ查询操作符之Select、Where、OrderBy、OrderByDescending、GroupBy、Join、GroupJoin及其对应的查询语法

    介绍    ·Select - Select选择:延迟    ·Where - Where查询:延迟    ·OrderBy - 按指定表达式对集合正序排序:延迟    ·OrderByDescend ...

随机推荐

  1. 3. C/C++笔试面试经典题目三

    64. 如何打印出当前源文件的文件名以及源文件的当前行号? [参考答案]cout << __FILE__ ; cout<<__LINE__ ; __FILE__和__LINE_ ...

  2. there is already 'RtController' bean method 项目报错

    今天开发项目时候发现项目报错启动的时候,也没有具体指的是哪一行报错,其实很简单的知道,首先看下报错信息: there is already 'RtController' bean method pub ...

  3. Exadata 18.1新特性--计算节点升级增强

    新的计算节点升级增强能大幅缩短升级花费的时间,最快能减少40%的时间,具体的增强主要体现在以下方面: 1.计算节点操作系统的备份工作. 以前计算节点操作系统的备份工作是在正式升级之前执行,在滚动升级过 ...

  4. SprimgMVC学习笔记(十)—— 拦截器

    一. 什么是拦截器? Spring MVC中的拦截器(Interceptor)类似于Servlet中的过滤器(Filter),它主要用于拦截用户请求并作相应的处理.例如通过拦截器可以进行权限验证.记录 ...

  5. ST第一章基础概念

    1.1程序由程序.数据.文档 测试对象 软件测试目的:发现尽可能多的软件缺陷,并期望通过改错把缺陷统统排除,提高软件质量 1.2 ST分类 1.2.1 方式分类 (1)静态测试 :不执行被测对象程序代 ...

  6. PHP 生成 MySql 数据库字典

    项目说明 通过配置 MySql 数据库信息,使用 PHP 生成数据表字典可以输出在当前页面,可以生成文件保存在指定位置,也可以下载格式支持网页HTML格式.CSV格式(Excel 读取).ZIP压缩格 ...

  7. C++_类和动态内存分配3-构造函数中使用new的注意事项

    如果在构造函数中使用new来初始化对象的指针成员时必须特别小心. 1 如果在构造函数中使用new来初始化指针成员,则应在析构函数中使用delete. 2 new和delete必须相互兼容.new对应于 ...

  8. C. Connect Three Round #528 (Div. 2)【曼哈顿距离】

    一.题面 题目链接 二.分析 这题的关键是要确定一个点是从三个点出发的交汇点,其他的只要结合曼哈顿距离的定义即可明白.因为是三个点,这个交汇点的坐标分别对应的就是x,y值的中值.然后一个小技巧就是曼哈 ...

  9. Tensorlflow-解决非线性回归问题

    import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt #使用numpy生成200个随机点,范围从-0.5到0 ...

  10. vue $index,$key已经移除了

    之前可以这样: <ul id="example"> <li v-for="item in items"> {{$index}} {{$k ...