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

RadGrid Export 2 Word....

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
raaj
Top achievements
Rank 1
raaj asked on 19 May 2010, 09:28 PM

Team,
I've Radgrid in my webpage bounded to Datasource. I want to export that Radgrid datas to MSWord.
For that, I wrote the following code in the Button Click event:

 

 

protected void Button1_Click(object sender, EventArgs e)

 

{

Response.Clear();

Response.Buffer =

true;

 

Response.AddHeader(

"content-disposition", "attachment;filename=FileName.doc");

 

Response.ContentEncoding = System.Text.

Encoding.UTF7;

 

Response.ContentType =

"application/vnd.word";

 

System.IO.

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

 

System.Web.UI.

HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

 

 

//this.GridView1.RenderControl(oHtmlTextWriter);

 

 

 

 

 

this.RadGrid1.RenderControl(oHtmlTextWriter);

 

Response.Output.Write(oStringWriter.ToString());

Response.Flush();

Response.End();

}



but its throwing error as shown in the screen shot.

The same code works fine for GridView. Is it not possible for RadGrid? Pls. provide me a solution.

Thanks,
Rajesh N.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 May 2010, 09:51 PM
Hello Rajesh,

You don't have to create your own exporting functionality - I recommend you use the built-in export to Word:
Word/Excel export (HTML-based)
Export Overview

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
raaj
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or