1. 前端绑定drowdownlist

a) 模板列datasource直接绑定

前端

     <asp:TemplateField HeaderText="Certificate Type" HeaderStyle-Width="10%"><ItemTemplate><asp:DropDownList ID="ddlCertificateType" runat="server" DataSource='<%# BindDdl()%>' DataValueField="iItemID" DataTextField="cField1"></asp:DropDownList></ItemTemplate><ItemStyle  HorizontalAlign="Left" /></asp:TemplateField>  

后台

    Protected Function BindDdl() As DataTableReturn tools.GetLookupList("CERTIFICATETYPE", "maintsort")End Function

b) 数据源绑定

      <asp:DropDownList ID="cboAccountType" Runat="server" AutoPostBack="True" Width="100%"DataSourceID="oDSAccountType" DataTextField="cField1" DataValueField="cField2" > </asp:DropDownList><asp:SqlDataSource ID="oDSAccountType" runat="server" ConnectionString="<%$ ConnectionStrings:VOSConnectionString %>" SelectCommand="VSP_Maintenance_GetItems" SelectCommandType="StoredProcedure"><SelectParameters><asp:Parameter DefaultValue="PAYSACCOUNT" Name="cCatCode" Type="String" /><asp:Parameter DefaultValue="SORTORDER" Name="cOrderBy" Type="String" /><asp:Parameter DefaultValue="0" Name="iNotForComboBoxes" Type="Int64" /><asp:Parameter DefaultValue="1" Name="RtnAllField" Type="Int64" /></SelectParameters></asp:SqlDataSource>

c)   绑定数据

   Private Sub BindRcbStudioManager()Dim dtStudioManager As DataTable = (New StudioMgr).GetStudioManager(Session("iStudioID"))Me.rcbstudioManager.DataSource = dtStudioManagerMe.rcbstudioManager.DataTextField = "studioManager"Me.rcbstudioManager.DataValueField = "iStudioManagerID"Me.rcbstudioManager.DataBind()End Sub

2.  Dropdownlist 特性

<asp:DropDownList ID="cboAccountType" Runat="server" AutoPostBack="True" Width="100%" > </asp:DropDownList>

如果AutoPostBack=True, 那么Postback时,添加的属性(Attributes)会丢失,因此添加属性的代码要写在IsPostback之外,
    这时需要在Page_Load时判断当前dropdownlist的当前选择值,比如: ucPaysBank.ascx.vb

a) 循环添加数据及属性

    Private Sub loadCboAccountType()Dim oTblAccountType As DataTable = tools.GetLookupListAll("PAYSACCOUNT", "SORTORDER", 1, 1, 1)cboAccountType.Items.Clear()For Each oRow As DataRow In oTblAccountType.RowsDim item As New ListItemitem.Text = oRow("cField1").ToStringitem.Value = oRow("iItemID").ToStringitem.Attributes.Add("cField2", oRow("cField2").ToString)cboAccountType.Items.Add(item)NextEnd Sub

b) 显示属性值

 dim cField2 as string = cboAccountType.SelectedItem.Attributes.Item("cField2")

c) 添加值

cboPayment.Items.Clear()
cboPayment.Items.Add(New ListItem("", -1))
cboPayment.Items.Add(New ListItem("Final Payment", 1))
cboPayment.Items.Add(New ListItem("N/A", 2))

d) 取值

   //获取value值$("#ddlSubmodel").val();//获取text值$("#ddlSubmodel").find("option:selected").text();

4. Dropdown List可以多选,且出现Checkbox  需引入

<link href="../App_Themes/bootstrap/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/bootstrap/bootstrap-multiselect.js"></script>

DropdownList 用法相关推荐

  1. @HTML.RadioButtonFor和@Html.DropDownList用法

    1.@Html.RadioButtonFor用法很简单 <label class="radio radio-inline">@Html.RadioButton(&quo ...

  2. asp:DropDownList用法

    DropDownList前台: <asp:DropDownList runat="server" ID="drop" AutoPostBack=" ...

  3. 精简DropDownList用法

    ViewBag.TypeID = new SelectList(db.TType, "ID", "Name", model.TypeID); @Html.Dro ...

  4. php dropdownlist,Yii2中DropDownList简单用法示例

    本文实例讲述了Yii2中DropDownList简单用法.分享给大家供大家参考,具体如下: 这里以实际应用为例讲解Yii2 DropDownList用法. 有一张分类表,无限极分类那种,表结构如下,p ...

  5. .net MVC 下拉多级联动及MVC Html.DropDownList 和DropDownListFor

    第一种方式 前台html <div style="margin:50px 0"><span>省份:</span><select id=&q ...

  6. php dropdownlist,Yii2框架dropDownList下拉菜单用法实例分析

    本文实例讲述了Yii2框架dropDownList下拉菜单用法.分享给大家供大家参考,具体如下: dropDownList是yii框架中一个自带的下拉功能了解,我们可以直接使用dropDownList ...

  7. DropDownList的用法

    DropDownList是一个下拉列表菜单,平时我们也会经常用到,下面就来看看如何绑定值 1>     静态添加,就是说在值都很明确的情况下 ListItem list1 = new ListI ...

  8. ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法

    http://www.cnblogs.com/youchun/archive/2009/12/27/1633655.html 转载于:https://www.cnblogs.com/modernsky ...

  9. js获取asp.net服务器端控件Label,TextBox,RadioButtonList,DropDownList的值

    在做 BS架构的项目时,经常遇到 需要用js 来调用 asp.net 服务器端控件的值. 大多数的 控件他的值都可以通过js调用它的 value属性来获得此控件的值,但是也有例外的情况. 经常用的 L ...

最新文章

  1. js表单提交,支持图片上传,包含后端php代码
  2. 虚拟化如何做实?详解戴尔2.0版解决方案
  3. 鸿蒙系统手机还会出吗,华为最强手机即将到来,可能还有华为鸿蒙系统加入!你期待吗?...
  4. xs_run加密还原
  5. Python入门100题 | 第011题
  6. 读jQuery之二十(Deferred对象)
  7. Linux内核深入理解中断和异常(7):中断下半部:Softirq, Tasklets and Workqueues
  8. 学生考勤系统设计mysql_学生考勤系统的设计与实现(Eclipse,MySQL)
  9. ubuntu19 磁盘分区管理及磁盘挂载
  10. 一周市场摘抄20210125
  11. 广发股票交易接口做什么的?
  12. Predicting drug–disease associations through layer attention graph convolutional network
  13. DDL、DML和DCL的理解(1、总述)
  14. 51nod2943 旅行者
  15. 英语听力采用计算机化考试,北京高考英语听力机考有什么特点?
  16. 软件质量保证与测试大作业,软件测试大作业.docx
  17. 离开手机的一天 天才小熊猫_文章《熊猫30天》
  18. SQL 2012 安装失败解决方案
  19. 【数据挖掘】聚类 Cluster 矩阵转换 数据矩阵 - 相似度矩阵 ( 二元变量简介 | 二元变量可能性表 | 对称二元变量 | 简单匹配系数 | 非对称二元变量 | Jaccard 系数 )
  20. Kotlin 学习笔记(十四)浅读协程

热门文章

  1. 腾讯云数据库的可信可控之路
  2. 2022年珠海市第三届半导体行业集成电路测试工竞赛成功举办
  3. createjs-打豆豆小游戏制作(3)
  4. MapReduce 数据倾斜以及解决思路
  5. 基于TIPTOP ERP应用的生产管理电子看板
  6. 全国铁路电话订票使用指南
  7. 企业怎样策划网络推广方案
  8. P2P网络借贷系统首选“凡途”--------凡途P2P专家
  9. Go学习笔记02-源码
  10. 国际电离层参考模型IRI2016的python包