有没有办法可以使用Devexpress ASPXGridViewExporter工具将Asp.net网格视图转换为PDF格式或任何其他格式,而无需将现有的gridview转换为Devexpress ASPXGridView?
答案 0 :(得分:3)
你可以这样做,但是对于出口,你需要通过一种循环方法。
首先,您需要拥有绑定到ASP gridview的datasourceID
。您可以按照导出步骤操作;应在导出按钮上单击以下代码。
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