如何在.net中获取checkboxlist中选中的值,每个值中间用逗号隔开,我做的在最前面多了一个逗号
protectedvoidButton1_Click(objectsender,EventArgse){Panel1.Visible=false;Panel2.Visib...
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
Label1.Text += CheckBoxList1.Items[i].Value+"#";
}
}
}
}
我用的有容器 展开
{
Panel1.Visible = false;
Panel2.Visible = true;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
Label1.Text += CheckBoxList1.Items[i].Value+"#";
}
}
}
}
我用的有容器 展开
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(',');
}
{
string s = "";
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected) s += li.Value + ",";
}
Label1.Text = s.TrimEnd(',');
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询