DropDownList控件的使用方法
1. 使用代码添加数据
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList> //1.1使用代码添加数据
ListItem item = new ListItem(".net","");
this.DropDownList1.Items.Add(item);
item = new ListItem("java", "");
this.DropDownList1.Items.Add(item);
item = new ListItem("php", "");
this.DropDownList1.Items.Add(item);
item = new ListItem("选择全部", "");
this.DropDownList1.Items.Insert(, item);//在第一个索引处添加‘选择全部’选项
2. 使用代码绑定数据源
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList> //2.1使用代码绑定数据源
CategoriesManager manager = new CategoriesManager();
this.DropDownList2.DataSource=manager.GetDataTable();
this.DropDownList2.DataTextField = "name";
this.DropDownList2.DataValueField = "id";
this.DropDownList2.DataBind();
this.DropDownList2.Items.Insert(,new ListItem("选择全部", ""));
3. 使用数据绑定控件绑定数据源
<asp:DropDownList ID="DropDownList3" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BookShopConnectionString %>"
SelectCommand="SELECT [Id], [Name] FROM [Categories]"></asp:SqlDataSource>
DropDownList控件的使用方法的更多相关文章
- Dropdownlist控件属性 OnSelectedIndexChanged方法不触发
<asp:DropDownList ID="ddlWJLX" runat="server" OnSelectedIndexChanged="dd ...
- 三级联动---DropDownList控件
AutoPostBack属性:意思是自动回传,也就是说此控件值更改后是否和服务器进行交互比如Dropdownlist控件,若设置为True,则你更换下拉列表值时会刷新页面(如果是网页的话),设置为fl ...
- Jquery获得控件值的方法
一 Jquery获得服务器控件值的方法 由于ASP.NET网页运行后,服务器控件会随机生成客户端id,jquery获取时候不太好操作,google了下,总结有以下3种方法: 服务器控件代码:<a ...
- DropDownList 控件
今天打算学习下dropdownlist控件的取值,当你通过数据库控件或dataset绑定值后,但又希望显示指定的值,这可不是简单的值绑定就OK,上网搜了一些资料,想彻底了解哈,后面发现其中有这么大的奥 ...
- DropDownList 控件的SelectedIndexChanged事件触发不了
先看看网友的问题: 根据Asp.NET的机制,在html markup有写DropDownList控件与动态加载的控件有点不一样.如果把DropDownList控件写在html markup,即.as ...
- 在FooterTemplate内显示DropDownList控件
如果想在Gridview控件FooterTemplate内显示DropDownList控件供用户添加数据时所应用.有两种方法可以实现,一种是在GridView控件的OnRowDataBound事件中写 ...
- monkeyrunner之坐标或控件ID获取方法(六)
Monkeyrunner的环境已经搭建完成,现在对Monkeyrunner做一个简介. Monkeyrunner工具提供了一套API让用户/测试人员来调用,调用这些api可以控制一个Android设备 ...
- DropDownList控件
1.DropDownList控件 <asp:DropDownList runat="server" ID="DropDownList1" AutoPost ...
- DropDownList 控件不能触发SelectedIndexChanged 事件
相信DropDownList 控件不能触发SelectedIndexChanged 事件已经不是什么新鲜事情了,原因也无外乎以下几种: 1.DropDownList 控件的属性 AutoPostBac ...
随机推荐
- Alpha阶段敏捷冲刺---Day2
一.Daily Scrum Meeting照片 PS:不要问我们为什么少了个人,某位不愿说出姓名的大佬强行申请要拍照 二.今天冲刺情况反馈 今天我们依旧在五社区五号楼719进行我们的每日立会.经过昨天 ...
- fiddler手机端抓包配置
首先,你得安装fiddler,这是前提条件,手机抓包有必须条件: 需要保持电脑和手机在同一个局域网中 (这一点,我一般会在电脑上启动一个wifi,然后手机连接即可) 下面说一下如何配置: 手机连接电脑 ...
- 解决eclipse maven install 造成JVM 内存溢出(java.lang.OutOfMemoryError: Java heap space)
maven install 报错信息: The system is out of resources.Consult the following stack trace for details.jav ...
- Python windows serial
Python windows serial 一.参考文章: Serial port programming http://www.cnblogs.com/2zhyi/p/3405339.html py ...
- Spring Boot 入门之消息中间件篇(五)
原文地址:Spring Boot 入门之消息中间件篇(五) 博客地址:http://www.extlight.com 一.前言 在消息中间件中有 2 个重要的概念:消息代理和目的地.当消息发送者发送消 ...
- 部署Web API后Delete请求总是报 405(Method Not Allowed)解决办法
WebDAV 安装IIS的时候如果选择了WebDAV(Web Distribution Authorization Versioning) Publish,则所有的 ...
- jvm jconsole
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=60001 -Djava.rmi.server.hostname=192. ...
- 远程连接Linux虚拟机上的mysql失败的解决方法
今天在虚拟机Ubuntu上折腾了一晚上mysql,然后试着用java连接,搞了很久都没成功,但是同学配好的Debian上却连接成功了,也就是说我的配置有问题. 折腾了很久,最后还是通过理解异常信息来大 ...
- 关于在github上 下载源码 clone 非 master 分支的代码
https://blog.csdn.net/u012302552/article/details/80680497
- Java前期(静态)绑定和后期(动态)绑定
Java前期(静态)绑定和后期(动态)绑定 程序绑定的概念:绑定指的是一个方法的调用与方法所在的类(方法主体)关联起来.对java来说,绑定分为静态绑定和动态绑定:或者叫做前期绑定和后期绑定. 静态绑 ...