Reputation: 25
Is there any way I can convert an Asp.net grid view to PDF format, or any other format, using the Devexpress ASPXGridViewExporter tool without converting the existing gridview to Devexpress ASPXGridView?
Upvotes: 1
Views: 3220
Reputation: 1236
You can do that, but for exporting you need to go through a round-about method.
First, you need to have the datasourceID
which you are binding to your ASP gridview. You can follow the steps for export; The following code should be written on Export Button Click.
ASPxGridView grd = new ASPxGridView(); //create instance of aspxgridview
grd.AutoGenerateColumns = true; //this should be set true so that automatically data gets bind
grd.ID = "Test"; //give any id
grd.DataSource = objs; //Datasource Id - could be objectdatasource
grd.KeyFieldName = "TestField"; //keyfield name in the datasource
this.Controls.Add(grd);
grd.DataBind();
ASPxGridViewExporter1.GridViewID = "Test";
ASPxGridViewExporter1.WritePdfToResponse();
this.Controls.Remove(grd); //would remove the temporarily created instance of devex grid
Upvotes: 3