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 ...
随机推荐
- hdu5012 bfs
比较简单的题 搜索4个方向,维护位子的值. #include<stdio.h> #include<string.h> #include<queue> using n ...
- Tomcat server.xml详解
Server.xml的结构大致 <Server port="8005" shutdown="SHUTDOWN"> <Service name= ...
- config 写入
d代码: # __author__ = liukun # coding:utf-8 line = input("please input the config \n :") #提示 ...
- Java编程思想学习(十五) 注解
注解Annotation又叫元数据,是JDK5中引入的一种以通用格式为程序提供配置信息的方式.使用注解Annotation可以使元数据写在程序源码中,使得代码看起来简洁,同时编译器也提供了对注解Ann ...
- BZOJ-1407 Savage 枚举+拓展欧几里得(+中国剩余定理??)
zky学长实力ACM赛制测试,和 大新闻(YveH) 和 华莱士(hjxcpg) 组队...2h 10T,开始 分工我搞A,大新闻B,华莱士C,于是开搞: 然而第一题巨鬼畜,想了40min发现似乎不可 ...
- UVA 11527 Unique Snowflakes
用STL做会很方便 SET: /*by SilverN*/ #include<iostream> #include<algorithm> #include<cstring ...
- Andriod Dialog 加载框 自定义,公用
怎门样,看图吧,我感觉还不错,很好,在让美工给你陪陪色,就完美了 代码呢放csnd 一份,收1分,百度网盘一份免费.我csdn 没分了,资助我下,谢谢了. http://download.csdn.n ...
- form表单只提交数据而不进行页面跳转的解决方案
一般的form提交操作写法为 代码如下: <form action="saveReport.htm" method="post"> …… <i ...
- c/c++细节知识整理
这篇文章总结了部分c/c++琐碎的细节知识. 目录如下: (一)bool类型 知识点出处较多,无法一一列举,向原作者致敬. (一)bool类型 在c99标准以前,c语言并没有定义bool类型.如果需要 ...
- 一种透明效果的view
设置这个view背景色: [UIColor colorWithRed: green: blue: alpha:0.3]; 效果如下: