zoukankan      html  css  js  c++  java
  • 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项/列

  • 相关阅读:
    Sql获取表中随机1到n条数据
    SQLite相关
    Eclipse自动生成api时报错“警告: 编码 GBK 的不可映射字符”
    Git基础命令
    Oracle查询结果行转列,列转行
    字符串编码方式转换
    Java字符串匹配正则表达式
    python爬虫--编码问题y
    GET与POST方法
    python爬虫(1)--Urllib库的基本使用
  • 原文地址:https://www.cnblogs.com/wangzl1163/p/6341143.html
Copyright © 2011-2022 走看看