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

            
                }
            }

    谢谢大家的支持,帮我点下需要的广告谢谢我会更加努力整理我的百科服务大家
  • 相关阅读:
    存储过程之基本语法
    SQL存储过程概念剖析
    SQL2005之SA提权总结
    关于存储过程
    Java开发环境之------MyEclipse快捷键和排除错误第一选择ctrl+1(***重点***:ctrl+1,快速修复---有点像vs中的快速using
    MyEclipse Servers视窗出现“Could not create the view: An unexpected exception was thrown”错误解决办法
    艾泰路由器端口映射怎么设置
    常用端口
    jdbc注册驱动 class.forName()
    MyEclipse不能自动编译解决办法总结
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835891.html
Copyright © 2011-2022 走看看