e diel, 9 shtator 2007

Export to Excel from pagination enabled Gridview

Recently couple of developers asked me this question, so thought of pinning it down here....

very simple way is to turn of your gridview pagination and bind it. As you must be aware use HTMLWriter to render you control.

................
htmlWrite.RenderBeginTag(HtmlTextWriterTag.Tr);
GridView4.AllowPaging = false;
GridView4.DataBind();
GridView4.RenderControl(htmlWrite);
htmlWrite.Write(" Header of my GridView");
htmlWrite.RenderEndTag();
htmlWrite.Write("
");
...........................

to make your excel look cool add/modify the htmlwriter settings....n e questions shoot me a mail :)

Nuk ka komente: