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 ...
随机推荐
- 本文分享一下ehcache的使用心得,本文主要讲以广播的形式同步缓存。
本文分享一下ehcache的使用心得,本文主要讲以广播的形式同步缓存. 下面讲述主要分为两个部分,一个是配置文件,一个是Java代码. 1.准备jar包: slf4j-api-1.7.12.jar,e ...
- 老男孩Day13作业:ORM学员管理系统
一.作业需求: 用户角色,讲师\学员, 用户登陆后根据角色不同,能做的事情不同,分别如下 讲师视图: 管理班级,可创建班级,根据学员qq号把学员加入班级 可创建指定班级的上课纪录,注意一节上 ...
- 最小生成树问题:Kruskal算法 AND Prim算法
Kruskal算法: void Kruskal ( ) { MST = { } ; //边的集合,最初为空集 while( Edge ...
- 安装opencv-python
1.安装包下载:在下面的网址下载对应版本及平台的 .whl 包,再手动安装. https://www.lfd.uci.edu/~gohlke/pythonlibs/ 2.将其拷贝到 Python 目录 ...
- (C/C++) Link List - C 語言版本
基本Link List 用C語言實現 先附上標頭檔 /** * @author Chen-Hao Lin * @email westgate.skater@gmail.com * @website h ...
- 批量改ID 行形式
update [Temp_Sql] set ID(字段) = (274+ID(字段)) 字段+字段形式 可以以行形式批量修改
- 首字母变大写(stringstream的应用)
Problem Description 输入一个英文句子,将每个单词的第一个字母改成大写字母. Input 输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行. O ...
- 【转】intellij idea使用指南—— 导入Eclipse的Web项目
通常一个团队中可能有人用eclipse,有人用intelliJ,那么经常会出现需要导入别人用eclipse建好的web项目.而IntelliJ提供了多种项目类型的导入方式,其中就有eclipse. 在 ...
- Vue keep-alive 组件.
如果不用 webpack , 那么 name 就是 vue.component(name) 这个 name 就是 export default { name:"index"} 的那 ...
- xml转换csv
/// <summary> /// xml文件转换为CSV /// </summary> /// <param name="fileName"> ...