CheckBoxList取值及勾选上

Code
            string strrighgs = "";
            
for (int i = 0; i < this.cblrighgs.Items.Count; i++)
            {
                
if (this.cblrighgs.Items[i].Selected == true)
                {
                    strrighgs 
+= this.cblrighgs.Items[i].Value+"|";
                }
            }

            
string str = "";
            
foreach (ListItem li in cblrighgs.Items)
            {
                
if (li.Selected == true)
                {
                    str 
+= li.Value+";";
                }
            }

            Response.Write(str);
            Response.End();
数据绑定实现勾选:

Code
            string[] strtemp = strapp.Split('|');
            
foreach (string str in strtemp)
            {
                
for (int i = 0; i < cblrighgs.Items.Count; i++)
                {
                    
if (this.cblrighgs.Items[i].Value == str)
                    {
                        
this.cblrighgs.Items[i].Selected = true;
                    }
                }
            }

posted on 2009-05-20 11:34  石牌村夫  阅读(1048)  评论(2编辑  收藏  举报