/// <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. P3230 [HNOI2013]比赛

    $ \color{#0066ff}{ 题目描述 }$ 沫沫非常喜欢看足球赛,但因为沉迷于射箭游戏,错过了最近的一次足球联赛.此次联 赛共N支球队参加,比赛规则如下: (1) 每两支球队之间踢一场比赛. ...

  2. 实现bootstrap的dropdown-menu(下拉菜单)点击后不关闭的方法 (转)

    实现bootstrap的dropdown-menu(下拉菜单)点击后不关闭的方法 问题描述,在下拉菜单中,添加其他元素,例如,原文作者所述的<a>和我自己实际用到的<input> ...

  3. angluarJs与后台交互小案例

    .myService.html: <!DOCTYPE HTML> <html ng-app="app"> <head> <title> ...

  4. P1613 跑路

    Luogu1613 #include<bits/stdc++.h> using namespace std; const int N=65; bool G[N][N][N]; int di ...

  5. 求一个区间里的一个x,这个x与这区间里面的所有数都互质

    链接:https://ac.nowcoder.com/acm/contest/301/H来源:牛客网 题描述 小乐乐上了一节数学课,数学老师讲的很好,小乐乐听的也如痴如醉. 小乐乐听了老师的讲解,知道 ...

  6. 【网络】CCNA实验一:Vlan、Trunk

    要求: 1:不同楼层物理隔离,但逻辑相连 2:相同楼层物理相连,但逻辑隔离 3:主机可以动态获取IP地址 4:不同VLAN间可以进行通信 5:主机最终访问www.esafenet.com弹出" ...

  7. Web API 解决跨域问题

    一.跨域问题的由来 同源策略:出于安全考虑,浏览器会限制脚本中发起的跨站请求,浏览器要求JavaScript或Cookie只能访问同域下的内容. 正是由于这个原因,我们不同项目之间的调用就会被浏览器阻 ...

  8. RESTful 设计工具和Web框架

    搭建开发环境几乎都搭建失败,因为需要FQ Spring Boot 和 Spring MVC 单独 Jersey官网可以直接访问 https://jersey.java.net/documentatio ...

  9. GreenPlum 大数据平台--基础使用(一)

    一,操作语法 01,创建数据库 --创建用户-- [gpadmin@greenplum01 ~]$ export PGDATABASE=testDB --指定数据库名字 [gpadmin@greenp ...

  10. shell 函数与内置变量

    1,特殊shell变量 $# 传递到脚本的参数个数 $* 以一个单字符串显示所有向脚本传递的参数 $$ 脚本运行的当前进程ID号 $! 后台运行的最后一个进程的ID号 $@ 与$*相同,但是使用时加引 ...