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项/列

相关文章:

  • 2021-09-20
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案