0

Hi Everyone,
Can somebody please help me with this.
I have this gridview and I have binded it properly,
now I have a button and I want to export the data inside the datagrid to excel.
I can do this in asp.net because the code is quite easy for the webform
but I am having a hard time in C# and it is a standalone application
I have googled it and found no step by step tutorial
I hope someone can help me
Thank you in advance.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by abelLazm
0

I find this code after searching check this one

string status = PolicyStatusDrpDown.SelectedIndex.ToString()=="0"?"open":"close";
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename="+objRLPCompanyInfo.CompanyAlias+" "+status+" "+DateRangeType.SelectedItem.ToString()+" "+System.DateTime.Today.ToLongDateString()+".xls");
Response.Charset = "";
this.EnableViewState = false;

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
BindGridControl();
//this.ClearControls(SimpleGridControl1);
SimpleGridControl1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();

details you can check this link it contains a sample applicaiton

Edited by abelLazm: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.