• CheckBoxList定义每行个数后,自动换行


    protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (CheckBoxList1.SelectedValue.Count() >0)
                {
                    //类别id
                    int categoryId = BLLUtils.Toint(DropDownList2.SelectedValue, 0);
    
                    //选中的属性的id
                    ArrayList propertyIds = new ArrayList();
                    for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
                    {
                        if (this.CheckBoxList1.Items[i].Selected == true)
                        {
                            propertyIds.Add(this.CheckBoxList1.Items[i].Value);
                        }
                    }
    
                    CheckBoxList2.Items.Clear();
                    for (int i = 0; i < propertyIds.Count; i++)
                    {
                        ProductPropertyValueDataSet ds = ProductPropertyValue.SelectValuePropertyDataById(categoryId, BLLUtils.Toint(propertyIds[i], 0));
                        if (ds != null && ds.Count > 0)    //有数据增加listitem
                        {
                            foreach (var item in ds.DataList)
                            {
                                CheckBoxList2.Items.Add(new ListItem(item.ValueProperty, item.ValueId.ToString() + "-" + propertyIds[i].ToString()));
                            }
    
                            if (CheckBoxList2.Items.Count < 12*(i+1))   //CheckBoxList的项数为12的倍数,每行不足12个补足12个无数据的不显示
                            {
                                for (int m = CheckBoxList2.Items.Count; m < 12 * (i + 1); m++)
                                {
                                    CheckBoxList2.Items.Add(new ListItem(" "," "));
                                    CheckBoxList2.Items[m].Attributes.Add("style", "display:none");
                                }
                            }
                            
                        }
                    }
                }
                else
                {
                    CheckBoxList2.Items.Clear();
                    return;
                }
            }


    注:在属性中已经指定每行12项/列

  • 相关阅读:
    MyEclipse去除网上复制下来的代码带有的行号
    Python人工智能第二篇
    Celery
    SQLAlchemy介绍
    MongoDB
    第三篇 Flask 中的 request
    linux安装
    第二篇 Flask 中的 Render Redirect HttpResponse
    第九篇 Flask 中的蓝图(BluePrint)
    第一篇 Flask
  • 原文地址:https://www.cnblogs.com/wangzl1163/p/6341143.html
Copyright © 2020-2023  润新知