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

dropdownlist控件的几个属性selectedIndex、selectedItem、selectedValue、selectedItem.Text、selectedItem.value的区别…1.selectedIndex——指的是dropdownlist中选项的索引,为int,从0开始,可读可写2.selectedItem——指的是选中的dropdownlist中选项,为ListItem,只读不写3.selectedValue——指的是选中的dropdownlist中选项的值,为string,只读不写4.selectedItem.Text——指的是选中的drop…


Jetbrains全系列IDE稳定放心使用

1. selectedIndex——指的是dropdownlist中选项的索引,为int,从0开始,可读可写

2. selectedItem——指的是选中的dropdownlist中选项,为ListItem,只读不写

3. selectedValue——指的是选中的dropdownlist中选项的值,为string, 只读不写

4. selectedItem.Text——指的是选中的dropdownlist中选项的文本内容,与selectedItems的值一样为string,可读可写

5. selectedItem.value——指的是选中的dropdownlist中选项的值,与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="1">北京</asp:ListItem>
            <asp:ListItem Value="2">上海</asp:ListItem>
            <asp:ListItem Value="3">广州</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;  
    }  
}  

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

原文

转载于:https://www.cnblogs.com/ZkbFighting/p/9469267.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/181194.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • 像素,分辨率,PPI(像素密度),BPP 扫盲

    像素,分辨率,PPI(像素密度),BPP 扫盲像素于分辨率像素,又称画素,为图像显示的基本单位,译自英文“pixel”,pix是英语单词picture的常用简写,加上英语单词“元素”element,就得到pixel,故“像素”表示“图像元素”之意,有时亦被称为pel(picture element)。每个这样的信息元素不是一个点或者一个方块,而是一个抽象的采样。仔细处理的话,一幅图像中的像素可以在任何尺度上看起来都不像分离的点或者方块;但…

    2022年5月11日
  • 在c语言中提供的条件运算符是什么_c语言条件运算符有哪些

    在c语言中提供的条件运算符是什么_c语言条件运算符有哪些Date:2020-02-01Author:SolerHOBook:CPrimerPlusDescription:条件运算符:?:C提供了条件表达式(conditionalexpression)作为表达ifelse语句的一种便捷方式,表达式使用:?:条件运算符。运算符分为两部分,需要3个运算对象。也就是所谓的三元运算符,也是C语言中的唯一的三元运算符。例如:x…

    2022年10月2日
  • USB协议简介「建议收藏」

    USB协议简介「建议收藏」1.USB协议简介https://blog.csdn.net/songze_lee/article/details/776580942017年08月28日23:20:16songze_lee阅读数:22978版权声明:本文为博主原创文章,未经博主允许不得转载。https://blog.csdn.net/songze_lee/article/details/77658094…

    2022年6月25日
  • random.nextInt()的用法

    random.nextInt()的用法1、不带参数的nextInt()会生成所有有效的整数(包含正数,负数,0)2、带参的nextInt(intx)则会生成一个范围在0~x(不包含X)内的任意正整数例如:intx=newRandom.nextInt(100);则x为一个0~99的任意整数3、生成一个指定范围内的整数/**生成[min,max]之间的随机整数*@parammin最小整数…

    2022年7月22日
  • 第一个ruby程序test.rb :)

    第一个ruby程序test.rb :)

    2021年4月25日
  • 移动端App开发流程管理

    移动端App开发流程管理前言刚刚做完一个项目,值得总结,在此记录一下。   欢迎加入学习小组QQ群: 156958554。项目流程一款应用的开发大体流程如下:1、项目立项:产品经理2、需求确认:产品经理(业务逻辑说明文档)3、业务确认:产品经理,技术经理,架构师4、业务架构:技术经理,架构师(业务流程文档)5、UI确认:产品经理,设计人员,开发人员全体6、

    2022年5月27日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号