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 ...
随机推荐
- CSS3媒体查询
随着响应式设计模型的诞生,Web网站又要发生翻天腹地的改革浪潮,可能有些人会觉得在国内IE6用户居高不下的情况下,这些新的技术还不会广泛的蔓延下去,那你就错了,如今淘宝,凡客,携程等等公司都已经在大胆 ...
- CentOS/Redhat VNC 服务
# yum install vnc-server vnc* (CentOS 5.x)# yum install tigervnc-server tigervnc (CentOS 6.x) [root@ ...
- BZOJ-3229 石子合并 GarsiaWachs算法
经典DP?稳T 3229: [Sdoi2008]石子合并 Time Limit: 3 Sec Memory Limit: 128 MB Submit: 426 Solved: 202 [Submit] ...
- org.springframework.beans.factory.annotation.Autowired(required=true)
Injection of autowired dependencies failed ERROR org.springframework.web.context.ContextLoader - Co ...
- ubuntu14.10建立热点wifi分享给手机
http://jingyan.baidu.com/article/363872ecd8f35d6e4ba16f97.html ubuntu14.10建立热点wifi分享给手机
- (Beta)Let's-版本发布说明
Let's App(Beta)现已隆重上市 GIT源码请戳此处 版本的新功能 我们在这一版本对于项目的规划目标主要集中在三个方面——预约用户观感,完善功能链条,改善用户体验 界面 首先,在β阶 ...
- PHP 7.1 新特性一览
可空类型主要用于参数类型声明和函数返回值声明.主要的两种形式如下:<?phpfunction answer(): ?int { return null; //ok}function ans ...
- 在.NET使用JSON作为数据交换格式
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://zhoufoxcn.blog.51cto.com/792419/517093 我们 ...
- Jquery插件easyUi表单验证提交
<form id="myForm" method="post"> <table align="center" style= ...
- 史上最详细的Android Studio系列教程四--Gradle基础
https://segmentfault.com/a/1190000002439306#articleHeader0