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. Verilog HDL那些事_建模篇笔记(实验一,实验二)

    实验一:永远的流水灯 扫描频率配置为100Hz,即是说扫描周期为10ms.这里需要注意的是扫描周期的概念.流水灯嘛,顾名思义,扫描周期指的是流水灯扫一轮所需要的时间.听到说周期,就应该想到在建模的时候 ...

  2. 3D Touch集成过程整理

    1.集成App图标按压快速打开某个功能 在AppDelegate.m中加入以下三个东西 在启动方法里加入3D Touch菜单 - (BOOL)application:(UIApplication *) ...

  3. Centos 安装vsftpd 服务器

    一:检查有没有安装vsftpd 二:安装vsftpd 三:安装之后重启 四:修改vsftpd配置文件 配置文件路径在/etc/vsftpd目录下 默认是注释掉的,把#号去掉 然后重启vsftpd 五: ...

  4. UML精粹5 - 状态图,活动图,通信图,组合结构,组件图,协作,交互概述图,时间图

    状态机图state machine diagram 下面是状态图的一个例子(一个城堡中的秘密保险箱的控制面板). 转换transition包括3个部分:trigger-signature [guard ...

  5. 动画_ _ Android应用开发之所有动画使用详解

    转载: http://blog.csdn.net/yanbober/article/details/46481171 题外话:有段时间没有更新博客了,这篇文章也是之前写了一半一直放在草稿箱,今天抽空把 ...

  6. gerrit集成gitweb:Error injecting constructor, java.io.IOException: Permission denied

    使用gerrit账户在centos上安装gerrit,然后集成gitweb,gerrit服务启动失败,查看日志,报错信息如下: [-- ::,] ERROR com.google.gerrit.pgm ...

  7. MySQL绿色版安装(mysql-5.7.12-win32)

    1. 从官网下载安装包:mysql-5.7.12-win32.zip 2. 解压到C盘(任意盘符都行) C:\mysql-5.7.12-win32 3. 修改配置文件:C:\mysql-5.7.12- ...

  8. finder的隐藏文件&IOS虚拟机地址

    在终端里输入下面命令即可让它们显示出来. defaults write com.apple.finder AppleShowAllFiles -bool true   如果想恢复隐藏,可以用这个命令: ...

  9. iOS官方Sample大全

    转载自:http://blog.csdn.net/yangtb2010/article/details/7005471 http://developer.apple.com/library/ios/s ...

  10. Android自动化学习笔记之MonkeyRunner:MonkeyRunner环境搭建

    ---------------------------------------------------------------------------------------------------- ...