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
- Drag WebGrid to the WebForm.
- Invoke ExportGrid() method to accept DynARInfo object.
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;
}
|
- Run the project.