Hello
I have a datagrid and one of its Templatecolumns contains a dropdownlist in its ItemTemplate.
When i try to export this in excel, the values of this column do not appear, i only see the headertext. Have you come across this problem before?
Here is the code i use in a button click:
I have a datagrid and one of its Templatecolumns contains a dropdownlist in its ItemTemplate.
When i try to export this in excel, the values of this column do not appear, i only see the headertext. Have you come across this problem before?
Here is the code i use in a button click:
Code:
dgEmployee.AllowPaging = false;
dgEmployee.Visible = true;
DataTable dt = (DataTable) ViewState["Employees"];
dgEmployee.DataSource = dt;
dgEmployee.DataBind();
dgEmployee.Columns[0].Visible = false;
dgEmployee.Columns[1].Visible = false;
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dgEmployee);
dgEmployee.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();