How to pass asp.net grid table data into HTML table

I work in asp.net and in that I use the grid view, and now I want to convert the grid view data that is dynamic for the html table, so I can send an email. if anyone knows this, please tell me. Thank you.

+4
source share
2 answers

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) { } 
+6
source

The Kettic GridView control can easily export data to the GridView in HTML and create an html file for viewing in a web browser or MS Word,

0
source

Source: https://habr.com/ru/post/1315161/


All Articles