zoukankan      html  css  js  c++  java
  • 无误选择列表项的值或文本 listbox,dropdownlist,radiobuttonlist 函数

    //选中选项
            public void SelectListIndex(ref ListControl wc, string textOrValue, bool isText)
            {

                string tempType = wc.GetType().ToString();
                tempType = tempType.Replace("System.Web.UI.WebControls.", "").ToLower();
                if (tempType == "listbox")
                {
                    if (isText)
                    ((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByText(textOrValue));
                    else
                    ((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByValue(textOrValue));

                }
                else if (tempType == "dropdownlist")
                {

                    if (isText)
                        ((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByText(textOrValue));
                    else
                        ((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByValue(textOrValue));

            
                }
                else if (tempType == "radiobuttonlist")
                {

                    if (isText)
                        ((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByText(textOrValue));
                    else
                        ((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByValue(textOrValue));

            
                }
            }

    谢谢大家的支持,帮我点下需要的广告谢谢我会更加努力整理我的百科服务大家
  • 相关阅读:
    mysql数据库
    Mysql之sql语句操作
    mysql修改root密码的多种方法
    kvm虚拟化
    清华AIOps算法:KPI聚类
    有点扯的预测方法
    内网安全运营的逻辑体系架构
    SpringBoot定时消费Kafka消息
    kafka的consumer消费能力很低的情况下的处理方案
    Kafka_Kafka 消费者 偏移量 与 积压 查询脚本 kafka-consumer-groups.sh
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835891.html
Copyright © 2011-2022 走看看