准備數據
標准顏色圖片
圖片尺寸
<asp:CheckBoxList ID=
OnDataBound=
AutoPostBack=
</asp:CheckBoxList>
從上面的數據
View Code
private List<string> ImageNames
{
get
{
List<string> o = new List<string>()
DirectoryInfo di = new DirectoryInfo(Server
FileInfo[] fiArray = di
for (int i =
{
o
}
return o;
}
}
綁定數據至CheckBoxList控件
View Code
protected void Page_Load(object sender
{
if (!IsPostBack)
{
Data_Binding()
}
}
private void Data_Binding()
{
this
this
this
}
CheckBoxList控件的OnDataBound=
View Code
protected void CheckBoxListColour_DataBound(object sender
{
var cbl = sender as CheckBoxList;
foreach (ListItem li in cbl
{
li
}
}
CheckBoxList控件的OnSelectedIndexChanged=
View Code
protected void CheckBoxListColour_SelectedIndexChanged(object sender
{
var cbl = sender as CheckBoxList;
foreach (ListItem li in cbl
{
if (li
{
li
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/12949.html