How to transfer asp.net grid view data in HTML table
I am working in asp.net and in that i am using grid view and now i want to convert grid view data which is dynamic to the html开发者_JAVA百科 table so i can send an email. if any one know it please tell me. Thank You
You can use
using System.IO;
using System.Text;
using System.Net.Mail;
private string GridViewToHtml(GridView gv)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
gv.RenderControl(hw);
return sb.ToString();
}
protected void SendMailButton_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.Body = GridViewToHtml(GridView1);
mail.IsBodyHtml = true;
// The same logic as you use for sending mail
}
public override void VerifyRenderingInServerForm(Control control)
{
}
The Kettic GridView control can easily export the data in GridView to HTML and create an html format file to viewing in a web browser or MS Word.
精彩评论