zoukankan      html  css  js  c++  java
  • 不能在DropDownList 中选择多个项

    在绑定DropDownList时如果出现多次绑定,会出错以下错误:

    “不能在DropDownList 中选择多个项”

    经了解,只需要在选中值是清空选择即可:xxDropDownList.ClearSelection() ;

      /// <summary>
        /// 设定选中项
        /// </summary>
        /// <param name="list"></param>
        public static void SetListControl(ListControl list, string selectedValues)
        {
            if (string.IsNullOrEmpty(selectedValues))
                return;
            list.ClearSelection();
            foreach (string var in selectedValues.Split(','))
            {
                string value = var.Trim();
                if (value.Length > 0)
                {
                    foreach (ListItem item in list.Items)
                    {
                        if (item.Value == value)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }
        }

  • 相关阅读:
    《挑战程序设计竞赛》 读后感
    基于SOAP的xml网络交互心得
    不用客户端,轻松下视频
    在cmd窗口中查询android的sqlite3数据库表之步骤
    单链表的插入删除以及逆转
    java中排序一个字符串数组
    求质因数
    指针与引用的区别
    统计查询-sql
    ---随心买统计查询
  • 原文地址:https://www.cnblogs.com/samlin/p/5889636.html
Copyright © 2011-2022 走看看