DropDownList的使用,RadioButtonList的使用
DropDownList的使用之从后台动态获取值
前端aspx代码如下
<asp:DropDownList ID="DDLTypeID" runat="server" >
</asp:DropDownList>
后台cs代码
private void DDLTypeIDBind()
{
DDLTypeID.DataSource = DBSqlHelper.getDataTable("select * from 表名 ");
DDLTypeID.DataTextField = "要绑定的名字";
DDLTypeID.DataValueField = "要绑定的id";
DDLTypeID.DataBind();
DDLTypeID.Items.Insert(, new ListItem("请选择职位", ""));
}
后台获取选中的值
string Type = Convert.ToInt32(DDLTypeID.SelectedValue);//说明DDLTypeID是DropDownList的id
jquery方式获取DropDownList选中的值
var ddl = document.getElementById("DropDownList的id");
var index = ddl.selectedIndex;
var Value = ddl.options[index].value;
RadioButtonList的使用
前端代码如下
<asp:RadioButtonList ID="radio" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Selected="true">女</asp:ListItem>
<asp:ListItem Value="1">男</asp:ListItem>
</asp:RadioButtonList>
后台获取值
int Sex = Convert.ToInt32(radio.SelectedValue);
RadioButtonList里面的选项默认就是互斥的,只能选一个。
DropDownList的使用,RadioButtonList的使用的更多相关文章
- Yii 生成表单下拉选框及查询下拉选框
CHtml类参考: http://www.yiichina.com/api/CHtml#activeDropDownList-detail activeDropDownList() 方法 public ...
- C# 控件
.ascx:Web窗体用户控件.用来存放独立的用户控件,可提供众多页面使用: <%@ Control Language="C#" AutoEventWireup=" ...
- ASP.NET开发,且编且改,分清职责
本篇Insus.NET使用一个实例,分享在ASP.NET开发时,一个功能一个方法(函数),且编且改,一步一个脚印把实例完成.在方法多变多形式的情况之下,怎样把写出来程序简单明了. 下面是一个Excel ...
- Jquery 操作CheckBox ,RadioButtonList,DropDownList
Jquery版本2.1.4 CheckBox 1.获取值: $("#chb").prop("checked"); RadioButtonList 1.获取值: ...
- Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中
http://blog.csdn.net/fox123871/article/details/8108030 <script type="text/javascript"&g ...
- WebForm复合控件RadioButtonList、CheckBoxList、DropDownList
1.RadioButtonList 单选集合 -属性:RepeatDirection:Vertical (垂直排布)/Horizontal (横向排布) RepeatLayout:Table ...
- js如何获取asp.net服务器端控件的值(label,textbox,dropdownlist,radiobuttonlist等)
js如何获取asp.net服务器端控件的值(label,textbox,dropdownlist,radiobuttonlist等) 欢迎访问原稿:http://hi.baidu.com/2wixia ...
- jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist生成客户端HTML标签后的value和text值
—.获取dropdownlist的text(ddlList为服务器端dropdownlist的ID,生成name属性等于ddlList的select标签) $("#ddlList optio ...
- ListBox,CheckBoxList,DropDownList,RadioButtonList的常见数据绑定
ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法 四个都是选择控件,用法大同小异,基本都是指定键值对: 直接加选择项: void way1( ...
随机推荐
- 如果在代码中使用JS
protected void Page_Load(object sender, EventArgs e) { //获得.js文件 string myscript = ...
- [转]没有了SA密码,无法Windows集成身份登录,DBA怎么办?
没有了SA密码,无法Windows集成身份登录,DBA怎么办? 原文:http://www.cnblogs.com/i6first/p/3512779.html 一同事反馈SQL无法正常登录了,以前 ...
- 【solr】java整合solr5.0之solrj的使用
1.首先导入solrj需要的的架包 2.需要注意的是低版本是solr是使用SolrServer进行URL实例的,5.0之后已经使用SolrClient替代这个类了,在添加之后首先我们需要根据schem ...
- 07 Linux su和sudo命令的区别
一. 使用 su 命令临时切换用户身份 1.su 的适用条件和威力 su命令就是切换用户的工具,怎么理解呢?比如我们以普通用户beinan登录的,但要添加用户任务,执行useradd ,beinan用 ...
- JAVA虚拟机垃圾回收算法原理
除了释放不再被引用的对象外,垃圾收集器还要处理堆碎块.新的对象分配了空间,不再被引用的对象被释放,所以堆内存的空闲位置介于活动的对象之间.请求分配新对象时可能不得不增大堆空间的大小,虽然可以使用的总空 ...
- (转)创建Graphics的三种方法
方法一.利用控件或窗体的Paint事件中的PainEventArgs 在窗体或控件的Paint事件中接收对图形对象的引用,作为PaintEventArgs(PaintEventArgs指定绘制控件所用 ...
- MyEclipse转换Eclipse项目无法启动问题(转)
将myeclipse中开发的动态web项目直接引入到eclipse中继续开发,启动tomcat时会发出警告,更重的问题是你想启动的项目不知哪里去了,没有读取到配置文件: 警告: [SetP ...
- centos 7 下安装Nginx
下载Nginx wget nginx.tar.gz http://nginx.org/download/nginx-1.11.3.tar.gz 解压源码 .tar.gz 然后进入目录编译安装 cd n ...
- 26. Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum Given a binary tree, find the maximum path sum. The path may start and ...
- Action<T1, T2>委托
封装包含两个参数的方法委托,没有返回值. 语法 public delegate void Action<in T1, in T2>( T1 arg1, T2 arg2 ) 类型参数 in ...