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.
-
C# Copy 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; }
- Run the project.
Tasks
Walkthrough: Allowing Export in WebGrid
How-to: Customize Export function
How-to: Export text when WebValueList is used
How-to: Use CacheToDisk feature to reduce memory usage
How-to: Set a different location for CacheToDisk feature
References
AllowExport Property
DynARInfo Class
ExportGrid() Method
Other Resources
Walkthrough Topics
How-to Topics