<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. iOS Simulator version 11 or later is currently not supported.

    iOS Simulator version 11 or later is currently not supported.You can open Xcode > Preferences > ...

  2. python_14 静态属性、类方法、静态方法;组合;继承

    静态属性 在类中函数前加@property,在实例调用函数时无需加(),将函数属性封装,调用时看起来与数据属性类似 将函数封装成数据属性的形式,外部调用时看不到逻辑,静态属性可以访问实例属性也可以访问 ...

  3. ----Androd 系统开机显示白条提示 “there is internal problem with your device, Contact your manufacture ... ”

    ref: https://www.theandroidsoul.com/how-to-fix-theres-an-internal-problem-with-your-device-error-on- ...

  4. 前端页面JS和CSS以及图片加载nginx报错:net::ERR_CONTENT_LENGTH_MISMATCH的解决与检查

    首先检查nginx权限 具体可参考地址https://www.cnblogs.com/hooly/p/9951748.html 或者百度其他方法 还有种情况,之前是可以用的,突然出现这种加载报错的情况 ...

  5. redis cluster介绍

    讲解分布式数据存储的核心算法,数据分布的算法 hash算法 -> 一致性hash算法(memcached) -> redis cluster,hash slot算法 一.概述 1.我们的m ...

  6. Linux seq_printf输出内容不完整的问题

    Linux seq_printf输出内容不完整的问题 写在前面的话:这是多年前在项目中遇到的问题,作为博客的开篇之作,有不足之处,请各位大侠斧正!谢谢! seq_file接口介绍 有许多种方法能够实现 ...

  7. 安装setuptools 报错缺少zlib

    # yum install zlib # yum install zlib-devel 下载成功后,进入python2.7的目录,重新执行 #make #make install 此时先前执行的 软连 ...

  8. freeswitch 使用info显示的通道变量

    2019-01-20 11:57:30.167311 [INFO] mod_dptools.c:1743 CHANNEL_DATA:Channel-State: [CS_EXECUTE]Channel ...

  9. pyinstaller,scrapy和apscheduler

    一.scrapy拉起方式 1. 简单cmd拉起 from scrapy.cmdline import execute spiders = [ 'scrapy crawl liepin', 'scrap ...

  10. paloalto防火墙执行初始配置

    1.默认情况下,防火墙的 IP 地址为 192.168.1.1,用户名/密码为 admin/admin. 为了安全起见,在继续执行其他防火墙配置任务之前,必须更改这些设置.必须从 MGT 接口(即使计 ...