Csharp:asp.net CheckBoxList databind
/// <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的更多相关文章
- ASP.NET CheckBoxList Operations with jQuery
		
本文描述了如何通过jQuery来对ASP.NET CheckBoxList控件进行一些基本操作,如通过value/text/index check/uncheck CheckBoxList,最小/最大 ...
 - 适当使用enum做数据字典 ( .net c# winform csharp asp.net webform )
		
在一些应用中,通常会用到很多由一些常量来进行描述的状态数据,比如性别(男.女),审核(未审核.已审核)等.在数据库中一般用数字形式来存储,比如0.1等. 不好的做法 经常看到一些应用(ps:最近又看到 ...
 - ASP.NET CheckBoxList 控件实现全选、反选、清除功能 利用js
		
直接看代码: JS代码如下: <script type="text/javascript" language="javascript"> funct ...
 - csharp:ASP.NET SignalR
		
http://signalr.net/ https://github.com/SignalR/SignalR http://www.asp.net/signalr http://www.cnblogs ...
 - 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. ...
 - C#.NET 通用控件数据源绑定类
		
using System.Data; using System.Collections; using System.Collections.Generic; using System.Web.UI; ...
 - .NET Web开发总结(五)
		
7 常用服务器控件 7.1 服务器控件概述 · 服务器控件是指在服务器上执行程序的代码的组件 通常这些服务器控件会提供 给用户一定的界面, 以便用户与服务器之间快速的交互 7.2 HTML 服 ...
 - Repeater控件实现数据绑定,并实现分页效果
		
前台显示代码 <pre name="code" class="csharp"><asp:Repeater ID="Repeater1 ...
 - LINQ查询操作符之Select、Where、OrderBy、OrderByDescending、GroupBy、Join、GroupJoin及其对应的查询语法
		
介绍 ·Select - Select选择:延迟 ·Where - Where查询:延迟 ·OrderBy - 按指定表达式对集合正序排序:延迟 ·OrderByDescend ...
 
随机推荐
- spark-2.2.1在centos7安装
			
前言 在安装Spark之前,我们需要安装Scala语言的支持.在此我选择的是scala-2.11.12版本.jdk8也要保证已经安装好并且配置好环境变量 scala-2.11.12下载 为了方便,我先 ...
 - 数据结构实验之图论七:驴友计划 ( 最短路径   Dijkstra 算法 )
			
数据结构实验之图论七:驴友计划 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Probl ...
 - 2.2、Softmax Regression算法实践
			
Softmax Regression算法实践 有了上篇博客的理论知识,我们可以利用实现好的函数,来构建Softmax Regression分类器,在训练分类器的过程中,我们使用多分类数据作为训练数据: ...
 - 洛谷 P1486 [NOI2004]郁闷的出纳员
			
题目描述 OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷的是,我们的老板反复无常,经常调整员工的工资 ...
 - Hibernate学习笔记(六)—— 查询优化
			
一.Hibernate的抓取策略 1.1 什么是抓取策略 抓取策略是当应用程序需要在(Hibernate实体对象图的)关联关系间进行导航的时候,Hibernate如何获取关联对象的策略. HIbern ...
 - python学习,day2:列表的使用,增删改合并等
			
# coding=utf-8 # Author: RyAn Bi names = ['A','B','C','D'] print(names) print(names[0]) #从0开始记录 prin ...
 - C++_函数3-引用变量与函数的默认参数
			
引用变量 C++新增了一种复合类型——引用变量. 引用是已定义的变量的别名.例如将twain作为clement变量的引用,则可以交替使用twain和clement来表示该变量. 引用变量的主要用途:用 ...
 - 非阻塞模式ServerSocketChannel 聊天室服务器端
			
import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import ja ...
 - ZOJ - 2042 模运算DP
			
解法见网上参考 这种只判断可达性的DP一般用bool 除非int能得到更多的信息 #include<iostream> #include<algorithm> #include ...
 - 在Linux系统下用dd命令制作ISO镜像U盘启动盘
			
http://os.51cto.com/art/201510/494762.htm 首先在 Linux 系统中打开终端,确认 U 盘路径: sudo fdisk -l 使用 dd 命令,格式如下: s ...