首页 > 解决方案 > 从复选框列表向多个号码发送短信

问题描述

从复选框列表中选择数字以发送短信

如何循环选择的每个数字

for (int i = 0; i < CheckBoxList2.Items.Count; i++)
{
    if (CheckBoxList2.Items[i].Selected == true)// getting selected value from CheckBox List  
    {
        str += CheckBoxList2.Items[i].Value + "" + "<br/>"; // add selected Item text to the String .  

        Label1.Text = str;
        //TextBox1.Text = str.ToString();
    }
}

向多个号码发送短信

标签: asp.net

解决方案


很简单,循环项目并将选中的项目添加到列表中。

List<string> list = CheckBoxList2.Items.Cast<ListItem>().Where(x => x.Selected).Select(y => y.Value).ToList();

然后您可以使用该列表发送短信。


推荐阅读