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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • OSPF原理及配置[通俗易懂]

    OSPF原理及配置[通俗易懂]OSPF原理及配置OSPF的特点OSPF运行原理OSPF区域及路由器身份OSPF区域OSPF身份OSPF邻居建立OSPF更新OSPF数据包类型DR、BDR的选举OSPF状态基本配置演示OSPF原理及配置OSPF(OpenShortestPassFirst,开放最短路径优先协议),是一个最常用的内部网管协议,是一个链路状态协议。OSP…

    2022年10月26日
  • 滑动窗口 leetcode_滑动窗口的概念

    滑动窗口 leetcode_滑动窗口的概念原题链接给你一个整数数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。返回滑动窗口中的最大值。示例 1:输入:nums = [1,3,-1,-3,5,3,6,7], k = 3输出:[3,3,5,5,6,7]解释:滑动窗口的位置 最大值————— —–[1 3 -1] -3 5 3 6 7

    2022年8月9日
  • 【Python】Jupyter在PyCharm中的使用

    【Python】Jupyter在PyCharm中的使用最近在学CS231n的课程,打算把作业做一下。由于官方给的例程是用的IPython,后缀名为ipynb,和之前接触的Python写法不一样,来记录一下自己今天踩到的一个坑。其实有一个很简单的解决方法就是安装Anaconda,我也不知道自己为什么要在PyCharm上死磕。步骤0安装Jupyterpipinstalljupyter1新建一个IPython文件这里

    2022年10月24日
  • centos 删除软链接(centos软路由)

    添加软连接软连接,为某一个文件在另外一个位置建立一个同步的连接在此处创建软连接后,访问到此处的软连接,就会定位到软连接指向的位置。相当于把一个文件夹放到了多个位置,但其实还是只有一份,并不是复制。具体用法是:ln-s源文件目标文件会针对源文件创建一个软连接(目标文件),链接到源文件。别搞反了。前面的源文件,是需要在当前位置能访问到的文件。后面的是目标文件,是新创建出来的链接。例…

    2022年4月14日
  • JVM调优工具总结「建议收藏」

    JVM调优工具总结「建议收藏」一、jps:虚拟机进程状况工具它可以列出正在运行的虚拟机进程,并显示虚拟机执行主类(MainClass,main()函数所在的类)名称以及正在运行的本地虚拟机唯一ID(LVMID);它是使用率最高的一个JDK命令行工具,因为其他的命令行工具都需要输入查询到的ID来确定要监控的是哪一个虚拟机进程。命令格式:jps[options][hostid]选项作用-q只…

    2022年5月6日
  • pytest fixtures_today fixture

    pytest fixtures_today fixturefixture的优势Pytest的fixture相对于传统的xUnit的setup/teardown函数做了显著的改进:命名方式灵活,不局限于setup和teardown这几个命名conf

    2022年8月6日

发表回复

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

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