我用到了下面方法, private string GridViewToHtml(GridView gv)
    {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        gv.RenderControl(hw);
        return sb.ToString();
    }  
    protected void SendMailInFO()
    {
      邮件发送
    }    protected void SendMail_Click(object sender, EventArgs e)
    {        SendMailInFO();  
    }
  我想知道怎么通过checkbox选中gridview的行,然后通过邮件发送,急。求帮助~~~!!!!

解决方案 »

  1.   

    在geidview中添加checkbox,要发送时遍历gridview的row,通过findcontrol方法找到checkbox,判断是否被选中,执行发送邮件的方法.
      

  2.   

                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    CheckBox checkbox = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
                    HtmlInputText Tex1 = (HtmlInputText)GridView1.Rows[i].Cells[0].FindControl("TextBox1");
                    HtmlInputText Tex2 = (HtmlInputText)GridView1.Rows[i].Cells[1].FindControl("TextBox2");
                    HtmlInputText Tex3 = (HtmlInputText)GridView1.Rows[i].Cells[2].FindControl("TextBox3");
                    HtmlInputText Tex4 = (HtmlInputText)GridView1.Rows[i].Cells[3].FindControl("TextBox4");
                    HtmlInputText Tex5 = (HtmlInputText)GridView1.Rows[i].Cells[4].FindControl("TextBox5");                if (Tex6.Value.Trim().Length == 0)
                    {
                        Tex6.Value = "0";
                    }
                    if (checkbox != null && checkbox.Checked == true)
                    {
                        sql="";
                    }
                }看看这个你就明白了
      

  3.   

    2楼正解GridView和CheckBox结合,请参考这篇文章
      

  4.   

    循环获取选中的checkbox行的邮箱 然后发送