我有一个问题要问。我的应用程序中有一个下拉列表。但是下拉列表填充了层次结构格式。请c图片
如上图。我如何加粗和下划线父菜单项,例如Men、Lady和NA另一方面,父项也不允许选择。
这是我的编码
private void createDDLCategory()
{
ddlCategory.AppendDataBoundItems = true;
ddlCategory.Items.Insert(0, new ListItem("All","A"));
ddlCategory.SelectedIndex = 0;
var ddl1 = dropdownlist.ddlCategoryWithoutGroup();
foreach (var value in ddl1)
{
if (value.P_CATEGORY_ID == null)
{
this.ddlCategory.Items.Add(new ListItem(value.CATEGORY_NAME, value.CATEGORY_ID.ToString()));
this.ddlCategory.Items.FindByValue(value.CATEGORY_ID.ToString()).Selected = false;
this.ddlCategory.Items.FindByValue(value.CATEGORY_ID.ToString()).Attributes.Add("disabled", "true");
this.ddlCategory.Items.FindByValue(value.CATEGORY_ID.ToString()).Attributes.Add("style", "font-weight:bold;");
foreach (var valueChild in ddl1)
{
if (valueChild.P_CATEGORY_ID == value.CATEGORY_ID)
this.ddlCategory.Items.Add(new ListItem(" " + valueChild.CATEGORY_NAME, valueChild.CATEGORY_ID.ToString()));
}
}
}
foreach (ListItem item in ddlCategory.Items)
{
item.Text = HttpUtility.HtmlDecode(item.Text);
}
}
感谢您的帮助。谢谢