怎么取得dropdownlist选中的ID值
把数据库绑定在dropdownlist中,然后把选中的dropdownlist的项的ID值保存在另外的一个数据库中.怎么取得dropdownlist选中的ID值呢??
this.DropDownList1.Items.Clear();
this.DropDownList1.DataSource = wwddt;
this.DropDownList1.DataTextField = "version_name";
this.DropDownList1.DataValueField = "version_id";
this.DropDownList1.DataBind();
因为显示的是"version_name"这个字段,我现在是想当选中"version_name"字段的项时,把"version_name"字段对应的"version_id"值存入另外的一个数据库中.
答案:
string a = dropdownlist.SelectedText;//获取选中的text
string b = dropdownlist.SelectedValue; //获取选中的value
int c = dropdownlist.SelectedIndex; //获取选中的索引
如果你的dropdownlist.datasource是在pageload里面绑定的话
很有可能是由于不断的初始化(不断的执行dropdownlist.datasource)导致每回都取道的默认值
一般用ispostback来回避这种情况
怎么取得dropdownlist选中的ID值的更多相关文章
- jquery设置checkbox状态,设置dropdownlist选中值,隐藏某控件,给某控件追加东西
jquery设置checkbox状态 $("[ID$=chkType]").attr("checked", true); jquery设置dropdownlis ...
- Javascript获取select下拉框选中的的值
现在有一id=test的下拉框,怎么拿到选中的那个值呢? 分别使用javascript原生的方法和jquery方法 <select id="test" name=" ...
- C# mvc DropDownList选中状态无效情况分析
情况: DropDownList控件使用List<SelectListItem>()设置下拉选项和默认值.当控件的Name和后台的ViewBag(或ViewData)的Key重复,会导致选 ...
- Jquery获取select,dropdownlist,checkbox下拉列表框的值
jQuery获取 Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); ...
- JavaScript- 获得TreeView CheckBox里选中项的值
获得TreeView CheckBox里选中项的值,对JSDOM控制还不是很熟,感觉不太容易.试了很多次终于成功了. 代码如下 <body> <form id="form1 ...
- jQuery获取radio选中项的值【转藏】
<title></title> <script src="js/jquery-1.7.2.min.js"></script> < ...
- js获取下拉列表(select)选中项的值和文本
获取下拉列表选中项的值和文本(select) <html> <head> <meta charset="utf-8"/> <title&g ...
- jquery实现全选、全不选、反选、获取选中的所有值总结
HTML 我们的页面上有一个歌曲列表,列出多行歌曲名称,并匹配复选框供用户选择,并且在列表下方有一排操作按钮. <!doctype html> <html> <head& ...
- easyui-combotree选中指定的值
选中根节点: //station_id为combotree控件id var station = $('#station_id').combotree('tree').tree('getRoots'); ...
随机推荐
- Qt - 错误总结 - 在自定义类头文件中添加Q_OBJECT 编译时报错(undefined reference to ‘vtable for xxThread)
错误提示:在添加的QThread子类头文件添加Q_OBJECT时,编译程序,出现"undefined reference to 'vtable for xxThread'"错误提示 ...
- React入门
一.引入Reactjs 方法一:直接下载相关js文件引入网页,其中react.js 是 React 的核心库,react-dom.js 是提供与 DOM 相关的功能,Browser.js 的作用是将 ...
- 整理一下Entity Framework的查询 [转]
Entity Framework是个好东西,虽然没有Hibernate功能强大,但使用更简便.今天整理一下常见SQL如何用EF来表达,Func形式和Linq形式都会列出来(本人更喜欢Func形式). ...
- 3 Git服务器搭建
1. 环境部署 系统环境:服务器端:CentOS 6.5 ,ip:192.168.56.1 客户端:CentOS 6.5 ,ip:192.168.56.101 软件版本:服务器端:源码编译安装,git ...
- 离线pip下载Python包
离线pip下载Python包 这几天搞Windows离线断网环境下安装Python包,配置环境,各种坑!做个记录,供以后查询吧. # 生产环境 windows xp# python 2 ...
- cocos2d-x宏定义
1 ccp : The "ccp" prefix means: "CoCos2d Point" //查看: ../cocos2d-x-2.2/cocos2dx/ ...
- ng-repeat
<html ng-app="compile"> <head> <script src="http://apps.bdimg.com/libs ...
- 关于display:none 和visibility:hidden 的区别
1.占据空间 :none 隐藏后不占据空间 visibility占据空间 2.回流与渲染:none产生回流与渲染 ? 可以通过oprea中的Profiler 工具测试. 关于回流的详细介绍:http: ...
- 限制textarea的字数(包括复制粘贴)
<textarea cols="100%" rows="10" id="tuconent" placeholder="评价( ...
- 【转】arm 开发工具比较(ADS vs RealviewMDK vs RVDS)
ADS REALVIEW MDK RVDS 公司 ARM Keil(后被ARM收购) ARM 版本 最新1.2 ,被RVDS取代 最新4.0 是否免费 破解情况 有 有 工程管理 CodeWarr ...