转自http://blog.csdn.net/iqv520/article/details/4419186

1. SelectedIndex ——选项的索引,为int,从0开始,可读可写

2. SelectedItem ——选择项,是一个对象,为ListItem,只读不写

3. SelectedValue —— 选项的值,为string, 只读不写

4. SelectedItem.Text ——选项的文本内容,与 SelectedItem的值一样为 string,可读可写

5. SelectedItem.Value ——选项的值,与 SelectedValue的值一样为 string,可读可写

示例

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dropdown.aspx.cs" Inherits="dropdown" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="">北京</asp:ListItem>
<asp:ListItem Value="">上海</asp:ListItem>
<asp:ListItem Value="">广州</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="check" /><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<br />
<asp:Label ID="Label3" runat="server" Text=""></asp:Label><br />
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text=""></asp:Label> </div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls; public partial class dropdown : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "selectedIndex=" + DropDownList1.SelectedIndex;
Label2.Text = "selectedItem=" + DropDownList1.SelectedItem;
Label3.Text = "selectedValue=" + DropDownList1.SelectedValue;
Label4.Text = "selectedItem.text=" + DropDownList1.SelectedItem.Text;
Label5.Text = "selectedItem.value=" + DropDownList1.SelectedItem.Value;
}
}

服务器控件的几个属性 SelectedIndex、SelectedItem、SelectedValue、SelectedItem.Text、selectedItem.value的更多相关文章

  1. dropdownlist控件的几个属性selectedIndex、selectedItem、selectedValue、selectedItem.Text、selectedItem.value的区别

    转自http://blog.csdn.net/iqv520/article/details/4419186 1. selectedIndex——指的是dropdownlist中选项的索引,为int,从 ...

  2. 服务器控件使用eval()绑定属性出现服务器标记的格式不正确

    在使用asp.net服务器端控件的时候,想要动态绑定控件某属性的值,或者动态绑定控件事件方法的参数,例如一个<asp:RadioButton ID="RadioButton5" ...

  3. 常用元素的属性/方法 attr / val / html /text

    常用元素的属性/方法 得到一个元素的高度, $("#myid").height() 得到一个元素的位置, $("#myid").offset() 返回的是一个o ...

  4. 闲记 单元格与单元格之间的边 ///字体属性都是font开头,除了颜色属性 ///文本属性都是text开的,除了设置行高。

    这两天一直在做网页没有什么太大的问题,期间也考了一场试,对答案的时候老师讲了一些小知识,因此来记录一下. 单元格与单元格之间的边距(cellspaling) list-type-image可以使用图像 ...

  5. jQuery - 03. each、prevaAll、nextAll、获取属性、修改属性attr/val/text()、jq.height/width、offset()./position()./scrol Left/Top 、事件绑定bind、delegate、on、事件解绑、事件对象、多库共存

    each 方法 $ ( selector).each(function( index,element) {  } );   参数一表示当前元素在所有匹配元素中的索引号 参数二表示当前元素(DOM对象) ...

  6. jQuery属性--html([val|fn])、text([val|fn])和val([val|fn|arr])

    html([val|fn]) 概述 取得第一个匹配元素的html内容,这个函数不能用于XML文档.但可以用于XHTML文档. 在一个 HTML 文档中, 我们可以使用 .html() 方法来获取任意一 ...

  7. Asp.net用户控件和委托事件

    在Asp.net系统制作过程中,门户类型的网站,我们可以用DIV+CSS+JS+Ajax全部搞定,但是一旦遇到界面元素比较复杂的时候,还是UserControl比较方便一些,各种封装,各种处理,然后拖 ...

  8. (转载)c# winform comboBox的常用一些属性和用法

    comboBox的常用一些属性和用法 [1].控件的默认值怎么设? this.comboBox1.Text = "请选择港口"; comboBox1.Items.Add(" ...

  9. winform公共标签和常用属性

    公共控件 1.Button(按钮): Enabled :确定是否启用控件 Visible:确定控件是否可见 2.CheckBox(多选项) CheckListBox -(多选项列表)可用CheckBo ...

随机推荐

  1. MVC Web.Config 配置错误

    配置一个MVC项目的 SessionState,查阅了大量的资料,发现都是直接在web.config中直接加入类似的语句就可以了 <sessionState timeout="60&q ...

  2. 【转载】.NET压缩/解压文件/夹组件

    转自:http://www.cnblogs.com/asxinyu/archive/2013/03/05/2943696.html 阅读目录 1.前言 2.关于压缩格式和算法的基础 3.几种常见的.N ...

  3. php 跨数据库调取数据

    我的这个是thinkphp,我就在 Application -> Common -> Conf -> config.php 文件里面配置数据库的地方,加入了下面这段代码 //'数据库 ...

  4. 为什么导入本地jquery.js老是无效?(已解决)

    我从jquery官网里复制过来jquery.js内容,然后粘贴到本地,但是引用的时候总是无效. 在翻看脚本所在目录,无意间发现脚本文件是个jquery.js.js,    原来是我的文件的扩展名的问题 ...

  5. Data Center(5): 实例

    我们来分析从外网访问内网的服务的具体过程: 首先我们看DNS和Load Balancer是怎么工作的. 客户端要访问我们的系统,发送了一个https请求,https://nova.mycompany. ...

  6. [Swift]LeetCode111. 二叉树的最小深度 | Minimum Depth of Binary Tree

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  7. [Swift]LeetCode168. Excel表列名称 | Excel Sheet Column Title

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  8. WebWorker与WebSocket实现前端消息总线

    Web Worker让JS有了多线程的能力,可以将复杂耗时的操作都交付给Worker线程处理.WebSocket让web端与服务端维持一个有效的长连接,实现服务端主动推送数据.将二者一结合,业务系统信 ...

  9. github pages代码高亮highlighter

    github pages 一直想添加代码高亮 highlighter ,基于 jekyll 3.0 的 rouge 终于搞定了: 下载代码高亮库 在 cmd 中输入: rougify style mo ...

  10. 微信小程序实战--集阅读与电影于一体的小程序项目(一)

    1.首页欢迎界面 项目目录结构 新建项目ReaderMovie,然后新建文件,结构如下 welcome.wxml <view class='container'> <image cl ...