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 {

            }
        }

posted on 2009-04-07 16:20  bestsaler  阅读(181)  评论(0编辑  收藏  举报