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的使用的更多相关文章

  1. Yii 生成表单下拉选框及查询下拉选框

    CHtml类参考: http://www.yiichina.com/api/CHtml#activeDropDownList-detail activeDropDownList() 方法 public ...

  2. C# 控件

    .ascx:Web窗体用户控件.用来存放独立的用户控件,可提供众多页面使用: <%@ Control Language="C#" AutoEventWireup=" ...

  3. ASP.NET开发,且编且改,分清职责

    本篇Insus.NET使用一个实例,分享在ASP.NET开发时,一个功能一个方法(函数),且编且改,一步一个脚印把实例完成.在方法多变多形式的情况之下,怎样把写出来程序简单明了. 下面是一个Excel ...

  4. Jquery 操作CheckBox ,RadioButtonList,DropDownList

    Jquery版本2.1.4 CheckBox 1.获取值: $("#chb").prop("checked"); RadioButtonList 1.获取值: ...

  5. Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中

    http://blog.csdn.net/fox123871/article/details/8108030 <script type="text/javascript"&g ...

  6. WebForm复合控件RadioButtonList、CheckBoxList、DropDownList

    1.RadioButtonList     单选集合 -属性:RepeatDirection:Vertical (垂直排布)/Horizontal (横向排布) RepeatLayout:Table ...

  7. js如何获取asp.net服务器端控件的值(label,textbox,dropdownlist,radiobuttonlist等)

    js如何获取asp.net服务器端控件的值(label,textbox,dropdownlist,radiobuttonlist等) 欢迎访问原稿:http://hi.baidu.com/2wixia ...

  8. jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist生成客户端HTML标签后的value和text值

    —.获取dropdownlist的text(ddlList为服务器端dropdownlist的ID,生成name属性等于ddlList的select标签) $("#ddlList optio ...

  9. ListBox,CheckBoxList,DropDownList,RadioButtonList的常见数据绑定

    ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法 四个都是选择控件,用法大同小异,基本都是指定键值对: 直接加选择项: void way1( ...

随机推荐

  1. arcgis server 10.2安装后,忘记Manager的用户名和密码

    arcgis server 10.2安装完毕后,需要创建站点,创建站点时,填写管理站点的用户名和密码.自己不小心,创建完毕后,给忘记了用户名和密码.求助Esri,解决方法如下: (1)找到arcgis ...

  2. 微信公众平台开发教程(十一)微信"企业号“上线

    什么是企业号? 企业号是微信为企业客户提供的移动应用入口 关注更安全 只有企业通讯录的成员才能关注企业号,分级管理员.保密消息等各种特性确保企业内部信息的安全. 应用可配置 企业可自行在企业号中可配置 ...

  3. JS获取当前日期时间及JS日期格式化

    Js获取当前日期时间: var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份( ...

  4. jquery 复制DIV与相关事件

    <div class="pages_img fix" name="fixpages">                <div class=& ...

  5. ios device model 详细内容

    参考 这里:https://theiphonewiki.com/wiki/Models http://en.wikipedia.org/wiki/List_of_iOS_devices http:// ...

  6. 简单的Web留言本

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. gerrit error: unpack failed: error Permission denied

    gerrit服务器迁移后,clone和pull代码到本地,都没问题. 但是,push时,报错: 查看了下git版本库存储目录,发现git下版本库镜像文件owner都是root.因为之前安装的gerri ...

  8. shutdown immediate时 hang住 (转载)

    shutdown immediate 经常关库时hang住,在alert中有 License high water mark = 4All dispatchers and shared servers ...

  9. 【练习】flushback基于时间的闪回查询

    1.创建table t1 :: SCOTT@ORA11GR2>create table t1 as select * from scott.emp; Table created. :: SCOT ...

  10. [LINUX] 查看连接数和IO负载

    Iostat 是 sysstat 工具集的一个工具,需要安装. Centos的安装方式是: yum install sysstat Ubuntu的安装方式是: aptitude install sys ...