[asp 3.5]1 export to Excel not working, other 2 almost identical ones do

michae0147l

New Member
I made a page that has 3 different places where it has an 'export to excel' button. All three are GridViews. They all follow the same pattern of:\[code\]Response.Clear();Response.Buffer = true;Response.ContentType = "application/vnd.ms-excel";Response.AddHeader("content-disposition","attachment;filename=Underlying.xls");Response.Charset = String.Empty;this.EnableViewState = false;StringWriter sw = new StringWriter();//some calculationsif (MyGridview.Rows.Count != 0){ChangeControlsToValue(MyGridview);HtmlTextWriter htw = new HtmlTextWriter(sw);MyGridView.RenderControl(htw);}this.EnableViewState = true;Response.Write(sw);Response.End();}\[/code\]The strange thing is, in one of the methods, there is no download. The other 2 work great and when debugging, up until the Response.Write(sw) there are no problems. The generated HTML works.Is there anyone here who can point me in the direction of what might be wrong? Why is there no download started?If I want to look at the contents of the Response object with Debug.Write(), which part of the Response Object do I need to look at?TIA
 
Top