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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend3days leftRegister
Posted Jun 21, 2011, 8:13 PM EDT
Do you want export the gridview data into HTML format?
Sweety45 reputationPosted Jun 21, 2011, 8:19 PM EDT
Posted Jun 21, 2011, 8:56 PM EDT
http://gchandra.wordpress.com/2006/08/23/export-datagrid-to-html/
Posted Jun 21, 2011, 9:05 PM EDT
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();
}
Sweety45 reputationPosted Jun 21, 2011, 9:06 PM EDT
Sweety45 reputationPosted Jun 21, 2011, 9:27 PM EDT
Posted Jun 21, 2011, 10:05 PM EDT