1

整个下午。

我有一个 gridview,每行“反馈”列提供一行。

更新后,一个漂亮的小消息框会显示“感谢您的反馈,我们会与您联系……等等”

我将如何获取 gridview 的这一编辑行并将其发送到电子邮件地址?

非常感谢 ac# .net 新手的任何帮助!

4

2 回答 2

0

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

在页面的 html 端添加 onRowCommand 事件:

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

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

protected void myCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandArgument == "feedback")
    {
        // Grab the row being edited, find the cell/control and get the text
    }
}
于 2010-02-04T15:50:33.480 回答
0

实际上,我使用了以下方法,这是一种享受:

 MailMessage feedbackmail = new MailMessage(
                "joe.bloggs@joebloggsland.co.uk",
                "joe.bloggs@joebloggsland.co.uk",
                "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());
            }
于 2010-02-08T17:02:09.260 回答