2010-02-04 25 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 
    } 
} 
相關問題