/// <summary>
/// CheckBoxList數據源
/// 塗聚文
/// 20130705
///
/// </summary>
private void setCheckBoxList()
{
DataTable dt = new DataTable();
CheckBoxList1.Items.Clear();
dt = geovindu_branchBLL.SelectGeovindu_branchNameDt();
CheckBoxList1.DataSource = dt;
this.CheckBoxList1.DataTextField = "B_Name";
this.CheckBoxList1.DataValueField = "B_EnglishName";
CheckBoxList1.DataBind(); } /// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
setCheckBoxList();
} }
/// <summary>
/// 獲取選擇的項目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
string variable = string.Empty;
int i = 0;
foreach (System.Web.UI.WebControls.ListItem oItem in CheckBoxList1.Items)
{
if (oItem.Selected) // if you want only selected
{
if (i ==0)
{
variable = oItem.Value;
}
else
{
variable = variable + "," + oItem.Value;
}
i++;
}
// otherwise get for all items
//variable = oItem.Value; } //傳值給父頁面
this.Page.Controls.Add(new LiteralControl(string.Format("<script>opener.document.form1.txtShoppingDealsBranch.value='{0}'</script>", variable))); //關閉此視窗
this.Page.Controls.Add(new LiteralControl("<script>window.close();</script>"));
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal" AppendDataBoundItems="True" DataTextField="B_Name" DataValueField="B_EnglishName" RepeatColumns="6" CellPadding="5"
CellSpacing="5" RepeatLayout="Table" BorderStyle="Outset" CssClass="geovindu">
</asp:CheckBoxList><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="確定" /></div>
<style type="text/css">

.geovindu INPUT
{
color:black;
border-style: none;
font-family: Tahoma;
font-size: 7px;
margin-right: 5px
} .geovindu td
{
/* font-size:x-large;*/
width:300px; } </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. js 事件的阶段

    事件有三个阶段: 1.事件捕获阶段 :从外向内 2.事件目标阶段 :最开始选择的那个 3.事件冒泡阶段 : 从里向外   为元素绑定事件 addEventListener("没有on的事件类 ...

  2. /bin/bash: sshpass: command not found

    按照如下命令进行安装即可: apt-get install sshpass

  3. In linux shell, How to cp/rm files by time?

    find /path/to/folder/ -mtime 1 -exec rm {} \; // Deletes all Files modified yesterday

  4. 【字符串】【hash】【倍增】洛谷 P3502 [POI2010]CHO-Hamsters 题解

        这是一道字符串建模+图论的问题. 题目描述 Byteasar breeds hamsters. Each hamster has a unique name, consisting of lo ...

  5. P4294 [WC2008]游览计划

    传送门 斯坦纳树 给一个联通图,求 $k$ 个关键点联通的最小生成树权值 设 $f[o][i]$ 表示当前关键点选择状态为 $o$ ,以点 $i$ 为根的树的最小权值 初始 $f[1<<( ...

  6. [转] 用Python建立最简单的web服务器

    [From] http://www.cnblogs.com/xuxn/archive/2011/02/14/build-simple-web-server-with-python.html 利用Pyt ...

  7. JavaScript学习笔记2_面向对象

    1.对象的定义 ECMAScript中,对象是一个无序属性集,这里的“属性”可以是基本值.对象或者函数 2.数据属性与访问器属性 数据属性即有值的属性,可以设置属性只读.不可删除.不可枚举等等 访问器 ...

  8. OPENROWSET read excel

    由于64位系统已经不支持 oledb 4.0访问 xls 1. 未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序 去http://download.microsoft. ...

  9. android点击桌面App图标activity启动流程

    1.点击桌面App图标,Launcher进程采用Binder IPC向system_server进程发起startActivity请求:2.system_server进程接收到请求后,向zygote进 ...

  10. Oracle DG --检查

    检查DG是否同步 01,  查看主备可切换状态 select switchover_status from v$database;select db_unique_name,open_mode,dat ...