iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
My company wishes to try to intercept the native Export to Excel on the WebGrid. They want to use Microsoft's DataGrid. I created a custom postback action.
When I take the datatable from the WebGrid, it only has the rows on the current page. Is there a way I can get all the rows? Here's a sample of the code. (It still doesn't work becuase when Response.End() occurs, I get a security error. Maybe you can help with this too. Even if I didn't get any rows, how can I trigger the web browser to recognize that I'm trying to send an excel file during the WebGrid FlyPostBack?)
void ctlGrid_InitializePostBack(object sender, PostbackEventArgs e) { if (e.Action == ISNet.WebUI.WebGrid.PostBackAction.Custom) { // double-check this is the GetCheckedRows button if (!string.IsNullOrEmpty( System.Web.HttpContext.Current.Request.Form["PrintToExcel"])) { PrintToExcel(sender, e); } } } private void PrintToExcel(object sender, PostbackEventArgs e) { WebGrid grid = (WebGrid)sender; grid.LayoutSettings.PagingExportMode = ClassicPagingExportMode.ExportAllData; DataTable dt = ((System.Data.DataView)e.DataSource).Table; DataGrid dg = new DataGrid(); dg.DataSource = dt; dg.DataBind(); System.Web.HttpContext.Current.Response.ClearContent(); string wgTableName = "Excel Export"; System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + wgTableName); System.Web.HttpContext.Current.Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); dg.RenderControl(htw); System.Web.HttpContext.Current.Response.Write(sw.ToString()); System.Web.HttpContext.Current.Response.End(); dg = null; dg.Dispose(); }
The reason we are trying to do this is it takes too long to create the excel file and when it does, it's currently limited to 65000 rows, which is not acceptable for our larger clients.
We are using WebGrid from WebStudioUI 2009 R2 SP1
Apologize for the delay in sending this.
I tried to reproduce the reported problem by creating a simple sample of a page containing WebGrid bind to “Products” table of Northwind database. The table has 77 rows. Classic paging is enabled on the grid’s control where 25 rows per page is set on the <LayoutSettings>.
When I take the data table in the InitializePostBack event, it has the entire rows instead of a number of rows which is currently shown in the selected page. Could you please help me by providing a running simple sample that I can use to observe the problematic behavior?
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname