Intersoft WebGrid Documentation
How-to: Invoke Export feature programmatically
See Also Send comments on this topic.

Glossary Item Box

WebGrid now has an ability to invoke the export feature without using 'Export' button on the right corner side of the grid. The export feature now can be invoked programmatically without the users interference anymore.

To Invoke Export feature programmatically in WebGrid

  1. Drag WebGrid to the WebForm.
  2. Invoke ExportGrid() method to accept DynARInfo object.

  3. C# Copy ImageCopy Code
    private void Button1_Click(object sender, System.EventArgs e)
    {   
       // invoke the grid's export feature   
       // through the server side   
       WebGrid1.ExportGrid(SetDynInfo());
    }
    
    private DynARInfo SetDynInfo()
    {   
       // configure the DynARInfo object   
       // as the parameter for the ExportGrid() method
                            
       // need to configure 4 things :   
       // dynInfo.ReportType   
       // dynInfo.ReportPath   
       // dynInfo.IISReportPath   
       // dynInfo.DynPageOrientation
                            
       DynARInfo dynInfo = new DynARInfo("html", Server.MapPath("~/TempReports") + @"\");   
       dynInfo.IISReportPath = "/TempReports/";   
       dynInfo.DynPageOrientation = PageOrientation.Portrait;   
       return dynInfo;
    }
    

  4. Run the project.

 

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.