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

ASP
ASP中通过该日历算法实现的具体代码
ASP类编写详细说明
一个简单的asp数据库操作类
一个asp快速字符串连接类
ByVal和ByRef(编写ASP子程序所用到命令)
FSO一些代码
ASP连接11种数据库语法总结
代码与页面的分离
ASP 类专题
直接保存URL图像或网页到服务器本地的类
[原创]关于Script的Defer属性
[ASP]使用类,实现模块化
在VBScript中使用类
浅谈ASP中的类
ASP中一个用VBScript写的随机数类
文件、目录,文本文件等多种操作类
Object对象的一些的隐藏函数介绍
ASP高亮类
叶子asp分页类
遭遇ASP类的事件设计

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


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

  通过事例学习.net的WebForms技术(三)
/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载 请保留完整版权信息
*/
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