Intersoft Support Center

Trigger Data Export in Server-side Programmatically

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.

    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;
    }
                            

  3. Run the project.

 

Previous Next