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 {

                }
            }

  • 相关阅读:
    Linux:Day7(上) find、文件特殊权限、if语句
    Linux:Day6(下) vim编辑器
    Linux:Day6(上) egrep、条件测试
    Linux:Day5 shell编程初步、grep
    Linux:Day4(下) 用户及组管理
    Linux中的cat、more、less、head、tail命令
    ajax中的contendType和dataType知识点梳理
    Django使用jsonp和cors解决跨域请求问题
    Django的Modelforms的介绍
    Django的Rbac介绍3
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835700.html
Copyright © 2011-2022 走看看