高亮CheckBoxList选中的项目(2)
this.CheckBoxListColour.DataBind();
}
CheckBoxList控件的OnDataBound="CheckBoxListColour_DataBound"事件。
View Code
protected void CheckBoxListColour_DataBound(object sender, EventArgs e)
{
var cbl = sender as CheckBoxList;
foreach (ListItem li in cbl.Items)
{
li.Text = string.Format("<img src='Colours/{0}' />", li.Value);
}
}
CheckBoxList控件的OnSelectedIndexChanged="CheckBoxListColour_SelectedIndexChanged"事件。
View Code
protected void CheckBoxListColour_SelectedIndexChanged(object sender, EventArgs e)
{
var cbl = sender as CheckBoxList;
foreach (ListItem li in cbl.Items)
{
if (li.Selected)
{
li.Attributes.Add("style", "background-color: red;");
}
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>