2

我想将所有选定的复选框项目发送到班级我如何发送它。如果我使用check1.selectedvalue/item它只发送一个。所以我该怎么做

protected void check1_SelectedIndexChanged(object sender, EventArgs e)
{
   for (int z = 0; z < check1.Items.Count; z++)
   {
      if (check1.Items[z].Selected)
      {
         string checking = "\u2022" + check1.Items[z].Text ;
      }
   }

   Mail emailsystem = new Mail();
   emailsystem.GetEmail(comment.Text, StatusList.SelectedValue, check1.SelectedValue);
}
4

2 回答 2

0

假设您使用的是CheckBoxList,您可以执行以下操作:

protected void check1_SelectedIndexChanged(object sender, EventArgs e)
{
    string result = string.Empty;

    foreach (ListItem listitem in check1.Items)
    {
        if (listitem.Selected)
        {
           result += ("\u2022" + listitem.Text);
        }
    }
    Mail emailsystem = new Mail();
    emailsystem.GetEmail(comment.Text, StatusList.SelectedValue, result);
}
于 2012-07-25T21:07:34.597 回答
0

您将需要连接选中复选框的文本并将其传递给您 emailSystem

protected void check1_SelectedIndexChanged(object sender, EventArgs e)
{
   string checking = "";
   for (int z = 0; z < check1.Items.Count; z++)
   {
      if (check1.Items[z].Selected)
      {
         checking += "\u2022" + check1.Items[z].Text;
      }
   }

   Mail emailsystem = new Mail();
   emailsystem.GetEmail(comment.Text, StatusList.SelectedValue, checking );
}
于 2012-07-25T21:11:54.347 回答