<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. 使用 nodeJs 开发微信公众号(设置自动回复消息)

    微信向第三方服务器发送请求时会降 signature .timestamp. nonce . openid(用户标识),发送内容会以 xml 的形式附加在请求中 回复消息前提我们得拿到用户id , 用 ...

  2. TXMLDocument 创建空值节点不要缩写

    TXMLDocument 创建空值节点不要缩写 xmldoc.CreateNode('input'); 然后访问 xmldoc.DocumentElement.XML <input/> 节 ...

  3. c#_生成图片式验证码

    废话不多说直接上代码. class Check_Code { /// <summary> /// 生成随机验证码数字+字母 /// </summary> /// <par ...

  4. failed to find global analyzer [uax_url_email]

    ES的默认分词设置是standard,这个在中文分词时就比较尴尬了,会单字拆分,比如我搜索关键词“清华大学”,这时候会按“清”,“华”,“大”,“学”去分词,然后搜出来的都是些“清清的河水”,“中华儿 ...

  5. liteUploader上传控件的封装使用

    //原来的绑定方式 $('#' + frm_name).liteUploader({ script: url, params: { type: "image", size: siz ...

  6. mybatis入门知识

    概述 MyBatis 是一个优秀的基于 Java 的持久层框架,它内部封装了 JDBC,使开发者只需关注 SQL 语句本身,而不用再花费精力去处理诸如注册驱动.创建 Connection.配置 Sta ...

  7. python windows环境响铃

    import winsound winsound.Beep(600,1000) #其中600表示声音大小,1000表示发生时长,1000为1秒

  8. dubbo 面试

    1.使用dubbo+zookeeper ,如果注册中心挂掉,是否可以继续通信?(zk集群可以达到高可用,但是如果全部挂掉呢?) 我答了不可以吧(项目没用过,自学没又这深度) 正确答案: dubbo使用 ...

  9. 16. 3Sum Closest (JAVA)

    Given an array nums of n integers and an integer target, find three integers in nums such that the s ...

  10. 机器学习入门:Linear Regression与Normal Equation -2017年8月23日22:11:50

    本文会讲到: (1)另一种线性回归方法:Normal Equation: (2)Gradient Descent与Normal Equation的优缺点:   前面我们通过Gradient Desce ...