2010-02-04 50 views
1

全部下午。已经在gridview中编辑过的电子邮件行

我有一个gridview,每行'feedback'列提供一行。

在更新,一个可爱的小消息框,说:“谢谢你的反馈,我们会联系你......等等,等等”

我怎么会去抓住在GridView的编辑过的行发送这到一个电子邮件地址?

任何帮助非常感谢一个c#.net新手!

回答

0

其实,我与工作一种享受以下去:

<asp:GridView ID="GridView1" runat="server" OnRowCommand="myCommand"> 
</asp:GridView> 

然后在后面的代码添加事件:

MailMessage feedbackmail = new MailMessage(
       "[email protected]", 
       "[email protected]", 
       "Subject", 
       e.NewValues.Values.ToString()); 

      SmtpClient client = new SmtpClient("SMTP"); 
      try 
      { 
       client.Send(feedbackmail); 
      } 
      catch (Exception ex) 
      { 
       Console.WriteLine("Email unable to be sent at this time", ex.ToString()); 
      } 
0

我假设您在该行中有一个按钮,用于生成发送反馈的命令。您可以将按钮上的CommandArgument设置为“反馈”,然后在onRowCommand事件中捕获它。

添加onRowCommand事件在你的页面的HTML端:

protected void myCommand(object sender, GridViewCommandEventArgs e) 
{ 
    if (e.CommandArgument == "feedback") 
    { 
     // Grab the row being edited, find the cell/control and get the text 
    } 
} 
相关问题