checkboxlist给label赋值
答案:1 悬赏:30 手机版
解决时间 2021-02-11 19:00
- 提问者网友:临风不自傲
- 2021-02-11 01:13
checkboxlist1有多项,勾选checkboxlist的每一项的值都会在label1上显示出来,当然已勾选的项在点击一次,label上所对应项也会消失,大家帮个忙
最佳答案
- 五星知识达人网友:何以畏孤独
- 2021-02-11 01:45
aspx
aaaaa
bbbb
ccccc
.cs
protected void CheckBoxList1_SelectedIndexChanged ( object sender, EventArgs e )
{
CheckBoxList checkBoxList = sender as CheckBoxList;
string strSelectedTexts = String.Empty;
string strSelectedValues = String.Empty;
foreach ( ListItem item in checkBoxList.Items )
{
if ( item.Selected )
{
strSelectedTexts += (item.Text + "
");
strSelectedValues += (item.Value + "
");
}
}
this.Label1.Text = strSelectedTexts;
}
aaaaa
bbbb
ccccc
.cs
protected void CheckBoxList1_SelectedIndexChanged ( object sender, EventArgs e )
{
CheckBoxList checkBoxList = sender as CheckBoxList;
string strSelectedTexts = String.Empty;
string strSelectedValues = String.Empty;
foreach ( ListItem item in checkBoxList.Items )
{
if ( item.Selected )
{
strSelectedTexts += (item.Text + "
");
strSelectedValues += (item.Value + "
");
}
}
this.Label1.Text = strSelectedTexts;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯