asp:DropDownList 使用
<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 使用的更多相关文章
- asp:DropDownList与asp:DataList的联合使用
情况:当在asp:DropDownLis点击选取其中的一个值来响应datalist的值. <form id="form1" runat="server"& ...
- ASP DropDownList部分选项无法触发回传问题
今天偶然碰到这个问题,一个通过后台绑定的DropDownList控件出现部分选项触发事件,部分选项不触发事件的问题: 原因是多个OPTION的Value值一致,导致ASP事件注册失败,只要在绑定过程中 ...
- js 获取asp:dropdownlist选中的值
var eSection = document.getElementById("<%=tx_ddlType.ClientID%>"); var eSectionValu ...
- jquery 设置asp:dropdownlist 选中项
$("#ddlPro").find('option').each(function () { this.selected = (this.text == dlprom); });
- Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件
在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...
- ASP.NET Repeater 绑定 DropDownList Calendar 选择日期
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- ASP.NET中使用DropDownList实现无刷新二级联动详细过程
Demo.sql create table Car( [id] int identity, ) not null, ) not null ) go insert into Car ([brand],[ ...
- 《ASP.NET1200例》嵌套在DataLisT控件中的其他服务器控件---DropDownList控件的数据绑定
aspx <script type="text/javascript"> function CheckAll(Obj) { var AllObj = document. ...
- ASP.NET笔记之 ListView 与 DropDownList的使用(解决杨中科视频中的问题)
1.Repeater用来显示数据.ListView用来操作数据 InsertItemTemplate和updateItemTemplate**Eval(显示数据)和Bind(双向绑定:不仅是需要展现, ...
随机推荐
- Jmeter学习记录
JSON正则表达式提取规则 https://www.cnblogs.com/hc1020/p/7723720.html Jmeter非GUI下执行日志 执行命令 ./jmeter -n -t $ ...
- HTTP和HTTPS协议,看一篇就够了
https://blog.csdn.net/xiaoming100001/article/details/81109617 因为http请求是无状态的,所以需要三次握手.四次挥手来确定状态. 大纲 这 ...
- Python学习日记 --day3
1.数据类型整体分析. int :1,2,3213,用于计算 bool:True False 用于判断 str:‘qweqweqe’ .‘我爱你中国’ .‘1234位朋友’ 储存少量的数据,进行 ...
- 一些java的demo
//1. false System.out.println(Integer.parseInt("01")>10); //2. abcdefghijklmnopqrstuvwx ...
- eval方法
1.作用 eval函数可计算某个字符串,并执行其中的Javascript代码 2.参数 eval函数的参数为一个string类型的字符串,不能是String()类型的对象 3.返回值 计算string ...
- [转载]EF或LINQ 查询时使用IN并且根据列表自定义排序方法
原文地址:EF或LINQ 查询时使用IN并且根据列表自定义排序方法作者:李明川 EF和LINQ改变了原有的手写SQL时期的一些编码方法,并且增强了各数据库之间的移植性简化了开发时的代码量和难度,由于很 ...
- Day06 - Ruby三种存取限制:Public,Protected,Private
前情提要: 在第五天的最后,我们提到了一句话“相同的class的实体也无法使用别人的singleton method”. 在今天,我们把焦点放在Ruby的method,继续了解存取限制:) Ruby经 ...
- (十)操作数据库、xlrd、xlwt补充
一.补充操作数据库: 1.建立游标时,指定返回的类型是字典 cur = coon.cursor(cursor=pymysql.cursors.DictCursor) 2.cur.fetchall() ...
- CMake support in Visual Studio
Visual Studio 2017 introduces built-in support for handling CMake projects. This makes it a lot simp ...
- HTTP 错误码
HTTP 400 – 请求无效 HTTP 401.1 – 未授权:登录失败 HTTP 401.2 – 未授权:服务器配置问题导致登录失败 HTTP 401.3 – ACL 禁止访问资源 HTTP 40 ...