Jump to content

Gridview


jteixeira

Recommended Posts

hi, I am devoloping, a web page and I have in a form a gridview with data, and I want to know how I do to sent by email the gridview data when i click in the button. I am workin in visual web developer in C#. I have this:

protected void Button3_Click(object sender, EventArgs e)	{	   MailMessage msg = new MailMessage();	   msg.From = new MailAddress("xxxx@xxxx.com", "Gestor");	   msg.To.Add(new MailAddress("xxxx@xxxx.com","Cliente"));	   msg.Subject	= TextBox1.Text;	   msg.Body	   = GetGridHtml();	   msg.IsBodyHtml = true;	   msg.Priority   = MailPriority.High;	   SmtpClient c   = new SmtpClient("hotmail.com");	   c.Send(msg);	}	private string GetGridHtml()	{		GridView1.DataSource = ObjectDataSource1.Select();		ObjectDataSource1.DataBind();		StringWriter writer = new StringWriter();		HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);		GridView1.RenderControl(htmlWriter);		return writer.ToString();	}

Anyone can help me?sorry my inglish. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...