如何在.net中获取checkboxlist中选中的值,每个值中间用逗号隔开,我做的在最前面多了一个逗号

2024-12-23 05:45:44
推荐回答(1个)
回答1:

protected void Button1_Click(object sender, EventArgs e)
{
string s = "";
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected) s += li.Value + ",";
}

Label1.Text = s.TrimEnd(',');
}