zoukankan      html  css  js  c++  java
  • c# 绑定checkboxlist 数据库的值函数

    public void BindCheckBoxList(CheckBoxList cbl, bool isText, string values)
            {
                values = string.IsNullOrEmpty(values) ? ("") : (values);
                if (values.Length > 0)
                {
                    if (isText)
                    {
                        string[] tempValues = values.Split(',');
                        for (int i = 0; i < tempValues.Length; i++)
                        {
                            for (int j = 0; j < cbl.Items.Count; j++) {
                                if (cbl.Items[j].Text.Trim() == tempValues[i].ToString())
                                {
                                    cbl.Items[j].Selected = true;
                                }
                            }
                        }
                    }
                    else {
                        string[] tempValues = values.Split(',');
                        for (int i = 0; i < tempValues.Length; i++)
                        {
                            for (int j = 0; j < cbl.Items.Count; j++)
                            {
                                if (cbl.Items[j].Value.Trim() == tempValues[i].ToString())
                                {
                                    cbl.Items[j].Selected = true;
                                }
                            }
                        }
                    }
                  
                }
                else {

                }
            }

  • 相关阅读:
    Elastic的should + bool 多字段完全匹配或查找
    MySQL慢日志
    Elastic的IN查找
    Elastic的字符串查找
    JavaScript获取当前时间戳
    原码, 反码, 补码学习笔记
    PHP渲染压缩HTML
    JavaScript的深拷贝
    JavaScript的变量的let const var的区别
    关于一个值该不该default null的判定
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835700.html
Copyright © 2011-2022 走看看