<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. HTML5 关于一些本地操作 cookie,sessionStorage,localStorage

    1,b/s 开发中经常会使用到 cookie,大部分情况下,都是由后端代码实现,那么 js 怎么实现对 cookie 的操作呢? <!DOCTYPE html> <html> ...

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

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

  3. python3字典练习(重要)

    #keys()返回字典里的所有的键dic = {'k1':'wcj','k2':33,'k3':[11,22,33,]}r = dic.keys()print(r) #结果为ict_keys(['k3 ...

  4. 修复Microsoft Store 无法连接网络 代码: 0x80072EFD

    事情的经过是这样的,我的Windows版本是1709,前两天刚从1703升上来,今天突然发现它自己给我装了个skype,我上Microsoft商店里查一下是什么情况,结果突然发现它又双双双不正常工作了 ...

  5. java 安装教程

    https://www.cnblogs.com/xuyangblog/p/5455381.html

  6. 云笔记项目-Spring事务学习-传播MANDATORY

    接下来测试事务传播属性MANDATORY Service层 所有Service层实现类都设置事务传播属性为MANDATORY. LayerT层代码 package LayerT; import jav ...

  7. appium+夜神模拟器+python安卓app爬虫初体验

    环境搭建:Windows 7 64bit jdk包:jdk-8u171-windows-x64.exe(http://www.oracle.com/technetwork/java/javase/do ...

  8. 定点CORDIC算法求所有三角函数及向量模的原理分析、硬件实现(FPGA)

    一.CORDIC算法 CORDIC(Coordinate Rotation DIgital Computer)是一种通过迭代对多种数学函数求值的方法,它可以对三角函数.双曲函数和平面旋转问题进行求解. ...

  9. IDEA添加项目依赖(将Tomcat中的servlet-api.jar添加到项目中去)

    File -> project structure -> Modules -> 右侧Dependencies -> 然后点加号把配置好的Tomcat的依赖包加进去

  10. java中java.exe,javac 在editplus中的配置

    java.exe,javac设置快捷键(editplus) 1.tools-preferences 2.add tools---program java关键字