ListBox1控件
前台:
- <div>
- <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" Height="66px" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged1" Width="80px">
- <asp:ListItem></asp:ListItem>
- <asp:ListItem></asp:ListItem>
- <asp:ListItem></asp:ListItem>
- <asp:ListItem></asp:ListItem>
- </asp:ListBox>
- <asp:Label ID="Label1" runat="server"></asp:Label>
- </div>
后台
第一种foreach循环
- protected void ListBox1_SelectedIndexChanged1(object sender, EventArgs e)
- {
- string strHobby = "";
- foreach (ListItem item in ListBox1.Items)
- {
- if (item.Selected)
- {
- strHobby += item.Value + "";
- }
- }
- Label1.Text = strHobby;
- }
for循环
- protected void ListBox1_SelectedIndexChanged1(object sender, EventArgs e)
- {
- string strHobby = "";
- for (int i = ; i < ListBox1.Items.Count; i++)
- {
- if (ListBox1.Items[i].Selected)
- {
- strHobby += ListBox1.Items[i].Value ;
- }
- }
- Label1.Text = strHobby;
- }
ListBox1控件的更多相关文章
- 常用的WebForm 控件
首先回忆一下Html页中的12个表单元素 .文本类 文本框 <input type="text" id="" name="" valu ...
- 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
[源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...
- WebForm(二)——控件和数据库连接方式
一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...
- winform窗体(二)——控件
一.窗体的事件 每一个窗体都有一个事件,这个窗体加载完成之后执行哪一段代码 位置:1)右键属性→事件→load 双击进入 2)双击窗体任意一个位置进入 删除事件:先将事件页面里面的挂好的事件删除,再删 ...
- winform窗体控件(全)
回顾跟补充下除了昨天那常用6个其他的winform窗体控件作用 1:Button:按钮 (1)AutoSize:如果是True的情况下,内容将会撑开:False的话会另起一行 (2)Enabled: ...
- WindowsForm公共控件--2016年12月5日
Button text:修改按钮显示的文字 CheckBox Checked:是否选中 CheckedListBox checkedListBox.Items.Add(显示的值,初始选中状态); ch ...
- C#常用控件介绍
目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox(文本框)控件 4.RichTe ...
- WebForm 常用控件
一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...
- ASPX.Net控件
简单控件 Label :显示文字,编译后的元素的为span 主要设置属性边框包括边框颜色,边框样式,边框粗细 Liteal :显示文字,编译后不会产生任何元素,一般用来从后台输出JS代码 Textbo ...
随机推荐
- php 判断是否get传值的参数是否存在
if(is_array($_GET)&&count($_GET)>0)//先判断是否通过get传值了 { if(isset($_GET["id&qu ...
- Java-集合类汇总
结构图: Collection ├List │├LinkedList │├ArrayList │└Vector │ └Stack └Set Map ├Hashtable ├HashMap └WeakH ...
- request.getAttribute() 和 request.getParameter() 有何区别?
HttpServletRequest类既有getAttribute()方法,也由getParameter()方法,这两个方法有以下区别: (1)HttpServletRequest类有setAttri ...
- Java编程思想学习(十一) 泛型
1.概要 generics enable types (classes and interfaces) to be parameters when defining classes, interfac ...
- BZOJ-1067 降雨量 线段树+分类讨论
这道B题,刚的不行,各种碎点及其容易忽略,受不鸟了直接 1067: [SCOI2007]降雨量 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 2859 ...
- UVA11400照明系统设计&& POJ1260Peals(DP)
紫书P275: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=105116#problem/A POJ http://poj.org/pr ...
- android加载大图片到内存
1)演示效果: 1)代码演示: 布局代码: 权限配置:
- PHP防止重复提交表单(helloweba网站经典实例)
<?php session_start(); header("Content-Type:text/html;charset:utf8"); function set_toke ...
- Thinkphp中验证码的使用以及验证的实现
<input class="TxtValidateCodeCssClass" id="captcha" name="captcha" ...
- Initialization of deep networks
Initialization of deep networks 24 Feb 2015Gustav Larsson As we all know, the solution to a non-conv ...