1.html

            <asp:CheckBox ID="CheckBox11" runat="server" onclick="changechecked(this)" />车身颜色:
<asp:DropDownList ID="DropDownList5" runat="server">
<asp:ListItem Text="红色" Value="红色的" Enabled="true" Selected="True"></asp:ListItem>
<asp:ListItem Text="绿色" Value="绿色的" />
</asp:DropDownList>

2.code

        protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Text一般用来前台显示给用户看的
//Value一般用于表单提交,提交给后台的数据
string l5_text = DropDownList5.SelectedItem.Text;//红色
string l5_value = DropDownList5.SelectedItem.Value;//红色的
string l5_value1 = DropDownList5.SelectedValue.ToString();//红色的
string text1 = DropDownList5.Items[].Text;//绿色
string value1 = DropDownList5.Items[].Value;//绿色的
bool IsSelected = DropDownList5.Items[].Selected; //绿色的
//t添加动态数据给下拉列表
DataSet ds = new DataSet();//此处只是举例,DataSet一定要实例化的
DropDownList5.DataSource = ds.Tables["dmsm1"].DefaultView;//"dmsm1"为数据库的名称
DropDownList5.DataTextField = "dmz";//dmz为数据库的字段名称
DropDownList5.DataValueField = "dmz";
DropDownList5.DataBind();
//添加静态数据给下拉列表
DropDownList5.Items.Insert(,"----请选择----");
DropDownList5.Items[].Selected = false;
DropDownList5.Items[].Selected = true ;
//DropDownList5.Items[1].Selected = true;
}
bool check2 = CheckBox2.Checked;
}

3.

C#_控件——DropDownList的更多相关文章

  1. C#控件DropDownList下拉列表默认打开

    c#中的控件DropDownList要实现默打开确实不容易,之前也是想过页面上的点击之后就打开了,那直接模拟点击不就行了,试过后大失所望,根本没有效果. 于是网上找到了一个例子能实现IE浏览器下的打开 ...

  2. (转).net控件dropdownlist动态绑定数据

    DropDownList控件的使用(数据绑定)(.net学习笔记二)(2006-10-12 07:28:49) 转载   分类:.net学习笔记 一.在页面初始化时候将集合绑定到DropDownLis ...

  3. .net控件dropdownlist动态绑定数据 ----转

    DropDownList控件的使用(数据绑定)(.net学习笔记二) 一.在页面初始化时候将集合绑定到DropDownListpublic void Page_Load(Object src.Even ...

  4. ASP.NET控件--DropDownList

      设置默认值:DropDownList1.Items[i].Selected=true;绑定:DropDownList1.DataSource = dataSet.Tables["Tabl ...

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

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

  6. C#_控件——CheckBox,TextBox,RequiredFieldValidator

    1. <asp:CheckBox ID="CheckBox2" runat="server" Text="你大爷" AutoPostB ...

  7. Asp.Net MVC绑定DropDownList等控件

    测试环境:vs2013..Net4.5.mvc5 一.Asp.Net MVC绑定控件原理说明 以Html.TextBox为例 /// <param name="name"&g ...

  8. JS如何得到Repeater中TextBox控件的值

    var subsidylCost = document.getElementById("txtSubsidylCost.ClientID").value; 这样获取不到,因为txt ...

  9. ASPNET服务端控件练习(一个机试题)

    简单记录: 模糊查询的select语句的拼写 public List<Model.Student> GetWhereStudent(string name, string sub, str ...

随机推荐

  1. oracle用户

    如果要了解oracle中用户信息,可以查询数据字典dba_users.在sql*plus中,使用system用户登录,查询语句如下: select username,account_status fr ...

  2. LSM树——放弃读能力换取写能力,将多次修改放在内存中形成有序树再统一写入磁盘

    LSM树(Log-Structured Merge Tree)存储引擎 代表数据库:nessDB.leveldb.hbase等 核心思想的核心就是放弃部分读能力,换取写入的最大化能力.LSM Tree ...

  3. 生成guid

    http://jingyan.baidu.com/article/84b4f565eebb9d60f6da3293.html

  4. 闲聊CSS之关于clearfix--清除浮动[转]

    .clearfix:after { content: " "; display: block; clear: both; height:; } .clearfix { zoom:; ...

  5. 一般处理文件.ashx中使用文件session遇到的问题

    在给其他网站提供接口的时候用ashx做的,在文件调用cs中的方法,方法中的Session报错:System.NullReferenceException: 未将对象引用设置到对象的实例. /// &l ...

  6. How to Run a .Jar Java File

    .jar files are used for archiving, archive unpacking. One of the essential features of jar file is l ...

  7. tarjan求强联通分量 模板

    void tarjan(int u) { dfn[u]=low[u]=++dfs_clock; stack_push(u); for (int c=head[u];c;c=nxt[c]) { int ...

  8. https://github.com/oneuijs/You-Dont-Need-jQuery

    https://github.com/oneuijs/You-Dont-Need-jQuery

  9. 都是以父元素的width为参照物的

    本文依赖于一个基础却又容易混淆的css知识点:当margin/padding取形式为百分比的值时,无论是left/right,还是top/bottom,都是以父元素的width为参照物的!也许你会说, ...

  10. 【codevs1036】商务旅行 LCA 倍增

    1036 商务旅行  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题目描述 Description 某首都城市的商人要经常到各城镇去做生意,他们按自己的 ...