using
System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public static
string Datatable2HTMLtable(DataTable dt)
{
try
{
GridView
dg = new GridView();
dg.AutoGenerateColumns
= true;
dg.DataSource
= dt;
dg.DataBind();
System.Text.StringBuilder sb = new
System.Text.StringBuilder();
System.IO.StringWriter sw = new
System.IO.StringWriter(sb);
HtmlTextWriter
htw = new HtmlTextWriter(sw);
dg.RenderControl(htw);
return sb.ToString();
}
catch (Exception
ex)
{
return "Datatable2HTMLtable
ERROR: " + ex.Message;
}
}