我有需要添加属性的复选框列表,但我注意到当我迭代控件时,没有...
var listType = SettingsManager.Get("CRMCaseTypes");
var listStatus = SettingsManager.Get("CRMStatusReasons");
var listTypeItems = ParseSettingList(listType);
var listStatusItems = ParseSettingList(listStatus);
cblCRMType.DataSource = listTypeItems;
cblCRMType.DataBind();
cblCRMStatus.DataSource = listStatusItems;
cblCRMStatus.DataBind();
int index = 0;
foreach (Control c in cblCRMStatus.Controls)
{
CheckBox cb = c as CheckBox;
if (cb != null)
{
cb.Attributes.Add("id", listStatusItems[index].Value);
if (cb.Attributes["id"] == "5")
{
cb.Checked = true;
cb.Enabled = false;
}
}
index++;
}
index = 0;
foreach (Control c in cblCRMType.Controls)
{
CheckBox cb = c as CheckBox;
if (cb != null)
{
cb.Attributes.Add("id", listTypeItems[index].Value);
}
index++;
}
}
有没有办法强制生成复选框?
谢谢