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 table so i can send an email. if any one know it please tell me. Thank You
我在asp.net工作,我正在使用网格视图,现在我想将网格视图数据转换为动态的html表,以便我可以发送电子邮件。如果有人知道,请告诉我。谢谢
2 个解决方案
#1
6
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)
{
}
#2
0
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.
Kettic GridView控件可以轻松地将GridView中的数据导出为HTML,并创建一个html格式文件,以便在Web浏览器或MS Word中查看。
#1
6
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)
{
}
#2
0
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.
Kettic GridView控件可以轻松地将GridView中的数据导出为HTML,并创建一个html格式文件,以便在Web浏览器或MS Word中查看。