当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 通过事例学习.net的WebForms技术(三)

ASP.NET
为T-SQL添加intellisense功能
SQL Server 2005安装过程中出现错误的解决办法
SQL Server 2005 RTM 安装错误 :The SQL Server System Configuration Checker cannot be executed due to
有关于JSON的一些资料
不能忽略c#中的using和as操作符的用处
JavaScript系列之―同步还是异步?
获取远程网页的内容之一(downmoon原创)
获取远程网页的内容之二(downmoon原创)
ASP.Net中防止刷新自动触发事件的解决方案
asp.net下用js实现鼠标移至小图,自动显示相应大图
Asp.Net 和 AJAX.Net 的区别
提交页面的定位--scrollIntoView的用法
利用AJAX与数据岛实现无刷新绑定
asp.net下判断用户什么时候离开,以什么方式离开
DataSet 添加数据集、行、列、主键和外键等操作示例
读写xml所有节点个人小结 和 读取xml节点的数据总结
收藏的asp.net文件上传类源码
asp.net下GDI+的一些常用应用(水印,文字,圆角处理)技巧
一个可以让.net程序在非WIN平台上运行的软件Mono
使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出

ASP.NET 中的 通过事例学习.net的WebForms技术(三)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 81 ::
收藏到网摘: n/a

DropDownList:
DropDownList 对应的Form 元素中的 <select ..> 我们同样对他的定义有两种方式
<asp:DropDownList id="dropdownlist1" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>
代码定义方式:
DropDownList dropdownlist1=new DropDownList();

比较关键的用到了属性主要是:
SelectedItem 这个属性是一个ListItem Class 我们紧接着就来讲解这个ListItem 属性

ListItem 属性,

由于我们对于DropDownList 最为关心的就是我们在对DropDownList进行选择以后我们得到的结果
所以,我们对ListItem 的最为关心的属性自然就是Text和 Value 这两个属性
Text 是ListItem 在外表所显示出来的结果
Value 是我们所选择的 Item 的真正的数值

综上,我们总结一下DropDownList 的 SelectedItem 属性的使用方法
dropdownlist1.SelectedItem.Text 和 dropdownlist1.SelectedItem.Value