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));

            
                }
            }

    谢谢大家的支持,帮我点下需要的广告谢谢我会更加努力整理我的百科服务大家
  • 相关阅读:
    理清一下JavaScript面向对象思路
    IE的CSS渲染跟其它浏览器有什么不同
    页面元素的CSS渲染优先级
    push与createElement性能比较
    关于JavaScript的push()函数
    关于JavaScript的沙箱模式
    JavaScript SandBox沙箱设计模式
    用live()方法给新增节点绑定事件
    深入JavaScript对象创建的细节
    Keras class_weight和sample_weight用法
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835891.html
Copyright © 2011-2022 走看看