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

ASP
冒泡算法的三种JavaScript表示
asp无限分级(递归调用)
VBS、ASP代码语法加亮显示的类
安全脚本程序的编写 V1.0
atom2rss.asp
atom_js.asp
google sitemap.asp
用ASP读取/写入UTF-8编码格式的文件
捌度空间 缓存类
再来个专门为google量身定做的sitemap生成代码,(可是动态的哦)
一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例
如何在ASP页面动态Inclue文件?
多域名一网站时如果返回最原来的域名
网页木马代码例子(里面的文件是漏洞扫描器,呵呵)
ASP万用分页程序
ASP项目中的公共翻页模块
在ASP中使用均速分页法提高分页速度
3种不同的方法生成文件
身份证校验算法与ASP程序
ASP抽取数据的执行效率

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 94 ::
收藏到网摘: 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