This is a migrated thread and some comments may be shown as answers.

[Solved] Export to Excel from an ascx

1 Answer 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sanket
Top achievements
Rank 1
Sanket asked on 25 May 2009, 04:58 PM
Hi,

Wanted to export the data in the Grid (in a user control) to Excel. It's not working. Basically, the File Download dialog with the message "Do you want to open or save this file" itself is not appearing.

So tried to put a test RadGrid like the following. The same method works when it's inside an aspx but not when it's in an ascx.

Why is this? Can you please me with this?

Thanks.

Copying the method which would be called when a button in the aspx or in the ascx is clicked.

 

public

 

void ExportToExcelButtonClick(object sender, EventArgs e)

 

{

Telerik.Web.UI.

RadGrid gv = new Telerik.Web.UI.RadGrid();

 

gv.DataSource =

new ArrayList();

 

 

 

 

 

gv.ExportSettings.ExportOnlyData =

true;

 

gv.ExportSettings.IgnorePaging =

true;

 

gv.ExportSettings.OpenInNewWindow =

true;

 

gv.MasterTableView.Caption =

"my caption";

 

gv.ExportSettings.FileName =

"exportGrid";

 

 

this.Controls.Add(gv);

 

gv.DataBind();

gv.MasterTableView.ExportToExcel();

}

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 May 2009, 07:42 AM
Hello Sanket,

Please examine the following link:
Export from ajaxified grid

Let us know if you need more information.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Sanket
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or