<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. Django ORM queryset object 解释(子查询和join连表查询的结果)

    #下面两种是基于QuerySet查询 也就是说SQL中用的jion连表的方式查询books = models.UserInfo.objects.all() print(type(books)) --- ...

  2. python安装selenium和下载浏览器驱动

    1.安装selenium     方法一:可以用在cmd中用pip命令安装. python默认自带pip工具,如果在电脑上配置了pip的环境变量,打开cmd命令窗口后可以直接输入命令pip insta ...

  3. stylus含有的特性

    Stylus 冒号可有可无 分号可有可无 逗号可有可无 括号可有可无 变量 插值(Interpolation) 混合(Mixin) 数学计算 强制类型转换 动态引入 条件表达式 迭代 嵌套选择器 父级 ...

  4. AQS原理以及AQS同步组件总结

    1 AQS简单介绍 2 AQS原理

  5. 初学python笔记----字符串

    ---恢复内容开始--- 1.在python中,用引号括起来的都是字符串,引号可以是单引号,也可以是双引号 2.修改字符串的大小写 3.字符串拼接用“+” 4.制表符("\t"), ...

  6. Mybatis useGeneratedKeys 填充自增主键值(使用Mysql)的原理分析

    一.Mybatis配置 <insert id="insert" parameterType="com.test.TestDO" keyProperty=& ...

  7. d3.js 平移缩放

    rt 记录一下 var zoom = d3.zoom() .scaleExtent([0.1,10]) .on("zoom", zoomed); function zoomed() ...

  8. React Native的学习资源网址

    react官方文档(英文): https://facebook.github.io/react/docs/getting-started.html   react中文社区(内部有视频教程等): htt ...

  9. ceph mimc版本ceph-deploy安装与配置

    系统环境centos7.6 内核5.0.9 YUM源配置 [root@k8s-sys-10-82-4-200 ceph-cluster]# cat /etc/yum.repos.d/ceph.repo ...

  10. 【1天】黑马程序员27天视频学习笔记【Day02】

    02.01常量的概述和使用 * A:什么是常量    * 在程序执行的过程中其值不可以发生改变 * B:Java中常量的分类    * 字面值常量    * 自定义常量(面向对象部分讲) * C:字面 ...