In my application i want to display the gridview data in the html format how can i do that
can any1 help me on this
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Jun 22, 2011, 2:05 AM
SweetyPosted Jun 22, 2011, 1:27 AM
SweetyPosted Jun 22, 2011, 1:06 AM
Posted Jun 22, 2011, 1:05 AM
private void Export(GridView ActiveProductsGrid)
{
string result = null;
Response.Clear();
Response.ContentType = "text/HTML";
using (var stringWriter = new StringWriter())
{
using (var htmlWriter = new HtmlTextWriter(stringWriter))
{
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Html);
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Body);
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Form);
var dg = new DataGrid { DataSource = (DataTable)ViewState["ProductTable"] };
dg.DataBind();
dg.RenderControl(htmlWriter);
htmlWriter.RenderEndTag();
htmlWriter.RenderEndTag();
htmlWriter.RenderEndTag();
}
// output the html
result = stringWriter.ToString();
Response.Write(result);
}
Response.Flush();
Response.End();
}
Posted Jun 22, 2011, 12:56 AM
http://gchandra.wordpress.com/2006/08/23/export-datagrid-to-html/
SweetyPosted Jun 22, 2011, 12:19 AM
Posted Jun 22, 2011, 12:13 AM
Do you want export the gridview data into HTML format?