Generally u will get "THREAD was Aborted" when u write any Response statements inside try - catch block.
On Fri, Nov 20, 2009 at 12:27 PM, Che Maddy <[email protected]> wrote: > > > Dear friends, > > i have a problem using grid view to export in excel inside the grid view > sheet and my code goes like > > > StringBuilder > stringBuilder = new StringBuilder(); > > StringWriter stringWriter = new StringWriter(stringBuilder); > > HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter); > > this.ClearControls(gvSearch); > > htmlTextWriter.WriteLine( > "<b><u><font size='5'> Item wise Report </font></u></b><br><font size='3'> > as on " + DateTime.Now.ToString("dd/MM/yyyy") + "</font>"); > > gvSearch.RenderControl(htmlTextWriter); > > HttpContext.Current.Response.Clear(); > > HttpContext.Current.Response.Charset = ""; > > HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; > > HttpContext.Current.Response.AddHeader("content-disposition", > "attachment;filename=Asset_Itemwise.xls"); > > HttpContext.Current.Response.Write(stringBuilder.ToString()); > > HttpContext.Current.Response.End(); > > HttpContext.Current.Response.Flush(); > ___________________________________________________________________ > > Error 1st shown : GridView control must be placed inside the form tags with > the runat = server attribute > > as i searched in google i found this snippet of code need to add as they > render the control in to the form... > > public override void VerifyRenderingInServerForm(Control control) > { > /* Confirms that an HtmlForm control is rendered for the specified ASP.NET > <http://asp.net/> > server control at run time. */ > > } > and i did then i got a error like THREAD was Aborted > > please check this and try to solve my problem... > > -- > Sarvesh > > > > -- > Sarvesh >
