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