标签中选定的复选框值 [英] selected checkbox value in a label
本文介绍了标签中选定的复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在标签中获取选定的复选框值.....请帮助我
how to get the selected checkbox value in a label.....help me Please
for (int itemcount = 0; itemcount < Rpt_Company.Items.Count; itemcount++)
{
CheckBox chkbox = ((CheckBox)Rpt_Company.Items[itemcount].FindControl("chkbox"));
if (chkbox != null && chkbox.Checked == true)
{
}
}
推荐答案
如果要求是获取Checked
CheckBox
的Text
值并分配给Label
,则可以使用以下LINQ
查询.
If the requirement is to get theText
value of theChecked
CheckBox
and to assign to theLabel
then the followingLINQ
query can be used.
CheckBox selectedCheckBox =
Rpt_Company.Items.OfType<checkbox>().FirstOrDefault (cb => cb.Checked );
if (selectedCheckBox != null) Label1.Text = selectedCheckBox.Text;
其中Items
是Controls
where Items
is collection of Controls
for (int itemcount = 0; itemcount < Rpt_Company.Items.Count; itemcount++)
{
CheckBox chkbox = ((CheckBox)Rpt_Company.Items[itemcount].FindControl("chkbox"));
if (chkbox != null && chkbox.Checked == true)
{
Label lbl = (Label)Rpt_Company.Items[itemcount].FindControl("chkbox"));
string lblid;
lblid= lbl.text
}
}
}
这篇关于标签中选定的复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文