Hi Alphonse,
I think if you want to get an Html table content from a given datatable,
generally we can consider either of the following means:
1. Since the System.Web.UI.W ebControls.Data Grid can be created on the fly
and render out its html content.
We may manually create a DataGrid instance (set AutoGenerateCol umns= true)
and bind the DataTable onto it , and call it's RenderControl method to
render into a HtmlTextWritter (created via a stringbuilder). After that , we
can get the datagrid's output html from the string builder. For example:
private void btnExport_Click (object sender, System.EventArg s e)
{
DataGrid dg = new DataGrid();
dg.AutoGenerate Columns = true;
dg.DataSource = GetDataTable();
dg.DataBind();
System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
System.IO.Strin gWriter sw= new System.IO.Strin gWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter( sw);
dg.RenderContro l(htw);
divTable.InnerH tml = sb.ToString();
}
#sb.ToString() will return the htmltable content we want.
2. Put the DataTable into a DataSet and use the DataSet.GetXml method to
retreive the DataSet's xml representation. Then, use some custom xslt style
to transform the xml into html table content. This require us to provide an
xslt style sheet.
Hope these help. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)