Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2006, 04:42 AM
Authorized User
 
Join Date: Mar 2006
Location: pune, Maharashtra, India.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in exporting datagrid to excel

Hi all,

I am using the datagrid containing the template columns. I have the code for exporting datagrid to excel sheet. I also have the code for deleting the controls in the template column before exporting it to the datagrid. but I am still getting an error because I have bounded the template columns using databinder.eval

I want to export datagrid to excel sheet. will anybody help me in this matter.

  #2 (permalink)  
Old May 31st, 2006, 08:42 AM
Authorized User
 
Join Date: Oct 2004
Location: Bangalore, , India.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try the following and let me know if you have any problem


Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=QuotationList.xls");
Response.Charset = "";

Response.Cache.SetCacheability(HttpCacheability.No Cache);

Response.ContentType = "application/vnd.xls";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

this.ClearControls(compareTable);

compareTable.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

Software proffesional from Bangalore,INDIA
  #3 (permalink)  
Old June 1st, 2006, 05:46 AM
Authorized User
 
Join Date: Mar 2006
Location: pune, Maharashtra, India.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

when I used the above code. I got following error

Server Error in '/schedule' Application.
--------------------------------------------------------------------------------

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +244
   schedule.timesheet.clearcontrols(Control control) +225
   schedule.timesheet.LinkButton1_Click(Object sender, EventArgs e) +203
   System.Web.UI.WebControls.LinkButton.OnClick(Event Args e) +108
   System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
   System.Web.UI.Page.ProcessRequestMain() +1263




  #4 (permalink)  
Old June 4th, 2006, 11:26 PM
Authorized User
 
Join Date: Feb 2006
Location: ahmedabad, Gujarat, India.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default


hi swati !!

just remove

Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.Cache.SetCacheability(HttpCacheability.No Cache);

this two statements

it will work
u can further mail me and ask anythign : jay4ever_2000@yahoo.com

bye





 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in exporting data from datagrid to Excel deb_kareng ASP.NET 2.0 Professional 4 August 4th, 2007 09:21 AM
exporting to excel from datagrid hotshot_21 ASP.NET 1.0 and 1.1 Basics 2 June 9th, 2006 08:53 AM
Exporting data to excel from datagrid, Problem. swadhinm ASP.NET 1.x and 2.0 Application Design 0 May 31st, 2005 01:44 AM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM
Exporting DataGrid To Excel chiefg C# 2 December 31st, 2003 12:23 PM



All times are GMT -4. The time now is 02:47 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.