﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Using Microsoft's DataGrid to Export Data Instead of Native WebGrid</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Using-Microsofts-DataGrid-to-Export-Data-Instead-of-Native-WebGrid/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Using Microsoft's DataGrid to Export Data Instead of Native WebGrid</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Using-Microsofts-DataGrid-to-Export-Data-Instead-of-Native-WebGrid/</link><pubDate>Sun, 20 Nov 2011 16:07:15 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;Apologize for the delay in sending this.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;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 &amp;lt;LayoutSettings&amp;gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;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?&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Using Microsoft's DataGrid to Export Data Instead of Native WebGrid</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Using-Microsofts-DataGrid-to-Export-Data-Instead-of-Native-WebGrid/</link><pubDate>Wed, 16 Nov 2011 08:29:06 GMT</pubDate><dc:creator>JohnnyBravo</dc:creator><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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?)&lt;/p&gt;&lt;pre&gt;        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=" &amp;#43; 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();   
            
        }&lt;/pre&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;We are using WebGrid from WebStudioUI 2009 R2 SP1&lt;/p&gt;</description></item></channel></rss>