<asp:DropDownList ID="DropDownList1" runat="server" onchange="return My_DropDownList1()" />

一、DropDownList后台数据绑定

1.DropDownList1.DataSource=DataSet.tables 绑定数据源。

2.DropDownList1.DataValueField="ID" 绑定主键。

3.DropDownList1.DataTextField=“Text” 绑定显示的文本。

4.DropDownList1.DataBind() 绑定数据。

二、DropDownList前台JavaScript获取选中项索引和获取选中项文本

<script type="text/javascript">
  function My_DropDownList1(){
    var DD_TXT=$('#DropDownList1 option:selected').text(); 获取选中项文本
    var DD_ID=$('#DropDownList1 option:selected').val(); 获取选中项文本对应的索引,也就是我们绑定的主键ID

  }
</script>

三、DropDownList后台通过事件获取文本和对应的索引值

DropDownList1.SelectedItem.Text     获取文本

DropDownList1.SelectedItem.Value  获取索引值

asp:DropDownList 使用的更多相关文章

  1. asp:DropDownList与asp:DataList的联合使用

    情况:当在asp:DropDownLis点击选取其中的一个值来响应datalist的值. <form id="form1" runat="server"& ...

  2. ASP DropDownList部分选项无法触发回传问题

    今天偶然碰到这个问题,一个通过后台绑定的DropDownList控件出现部分选项触发事件,部分选项不触发事件的问题: 原因是多个OPTION的Value值一致,导致ASP事件注册失败,只要在绑定过程中 ...

  3. js 获取asp:dropdownlist选中的值

    var eSection = document.getElementById("<%=tx_ddlType.ClientID%>"); var eSectionValu ...

  4. jquery 设置asp:dropdownlist 选中项

    $("#ddlPro").find('option').each(function () { this.selected = (this.text == dlprom); });

  5. Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件

    在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...

  6. ASP.NET Repeater 绑定 DropDownList Calendar 选择日期

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  7. ASP.NET中使用DropDownList实现无刷新二级联动详细过程

    Demo.sql create table Car( [id] int identity, ) not null, ) not null ) go insert into Car ([brand],[ ...

  8. 《ASP.NET1200例》嵌套在DataLisT控件中的其他服务器控件---DropDownList控件的数据绑定

    aspx <script type="text/javascript"> function CheckAll(Obj) { var AllObj = document. ...

  9. ASP.NET笔记之 ListView 与 DropDownList的使用(解决杨中科视频中的问题)

    1.Repeater用来显示数据.ListView用来操作数据 InsertItemTemplate和updateItemTemplate**Eval(显示数据)和Bind(双向绑定:不仅是需要展现, ...

随机推荐

  1. pyqt5 -——基本功能(HelloWorld)

    一. 简单窗口 这个简单的小例子展示的是一个小窗口.但是我们可以在这个小窗口上面做很多事情,改变大小,最大化,最小化等,这需要很多代码才能实现.这在很多应用中很常见,没必要每次都要重写这部分代码,Qt ...

  2. tomcat Server启动带profile文件

    一般mvn如果配置有环境,直接在tomcat server中无法直接启动,需要在vm或者tomcat启动中添加profile启动. pom.xml中添加: 在<profile>中添加默认p ...

  3. codeblock 恢复默认字体设置

    默认字体为:Courier New   我使用的codeblock版本为:17 .12. 今天我想调整一下codeblock的代码驱的字体,根据设置:settings->Editor->F ...

  4. 39_redux_counter应用_redux版本

    一.下载 要想使用redux,首先要下载它 npm install --save redux 二.核心API 1.createStore() 作用:创建包含指定reducer的store对象 编码:i ...

  5. linux程序一般设置

    看canal的时候看了下deploy的脚本,发现很多系统都大同小异 如果是需要debug,就需要开启调试端口 if [ "$1" = "debug" ]; th ...

  6. Unable to find a single main class from the following candidates ,显示有两个main class

    由于基础框架是用的网上down的源码,我将项目名字改了,估计没有进行maven clean,本地调试的时候没有问题. 当发布时候,执行maven install 一直提示上述错误. 解决办法:1.ma ...

  7. TIMESTAMP类型字段在SQL Server和MySQL中的含义和使用

    公众号上转的满天飞的一篇文章,MySQL优化相关的,无意中瞄到一句“尽量使用TIMESTAMP而非DATETIME”,之前对TIMESTAMP也不太熟悉,很少使用,于是查了一下两者的区别. 其实,不管 ...

  8. VS code自定义用户代码片段snippet

    打开VS code,“文件-首选项-用户代码片段-选择新建全局代码片段文件 “ 属性介绍:prefix   就是你自定义的快捷键 body    就是你自定义的代码片段 description 就是这 ...

  9. 《转》完美解决微信video视频隐藏控件和内联播放问题

    地址:https://blog.csdn.net/xiao190128/article/details/81025378 var u = navigator.userAgent; var isAndr ...

  10. maven的pom.xml文件详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...