我在复选框列表中查找选中的项目时遇到问题。实际上,复选框列表的列表项是从数据库加载的。但是通过使用下面的代码,我无法在列表中找到选中的项目,并且这些项目总是返回 false。下面是我的代码有人可以帮我吗?
protected void GetCheckboxlist_Click(object sender, EventArgs e)
{
string s = string.Empty;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
// List the selected items
s = s + CheckBoxList1.Items[i].Text + ",";
}
}
}