Question

Afternoon all.

I have a gridview that offers a line per line 'feedback' column.

Upon updating, a nice little message box says "Thanks for the feedback, we'll be in touch...etc, etc"

How would I go about grabbing this edited row of the gridview and send this to an email address?

Any help greatly appreciated for a c# .net novice!

Was it helpful?

Solution 2

I actually went with the following that worked a treat:

 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());
            }

OTHER TIPS

I'm assuming that you have a button in that row that is being used to generate the command to send the feed back. You could set the CommandArgument on the button to "feedback" and then capture it during the onRowCommand Event.

Add the onRowCommand event in the html side of your page:

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

Then add the event in the code behind:

protected void myCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandArgument == "feedback")
    {
        // Grab the row being edited, find the cell/control and get the text
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top