Web Grid cannot export filtered data in virtual load mode and server side binding

1 reply. Last post: November 25, 2016 7:50 AM by Yudi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Gusdianto MrMember

We have a webgrid view using the setting below:

        <ISWebGrid:WebGrid ID="WebGrid1" runat="server" Height="500px" UseDefaultStyle="True" Width="1000px" OnExport="WebGrid1_Export"
                 DefaultStyleMode="Elegant" DataCacheStorage="Session"
                 OnInitializeDataSource ="WebGrid1_InitializeDataSource" OnPrepareDataBinding="WebGrid1_PrepareDataBinding" OnCustomAggregate="WebGrid1_CustomAggregate">
                 <LayoutSettings PagingMode="VirtualLoad" VirtualLoadMode="LargeData"
                    AllowExport="Yes" PagingExportMode="ExportAllData"
                    AllowFilter="Yes" AllowSorting="Yes" ColumnFooters="Yes">
                </LayoutSettings>

 

 And we use server side data binding instead of client side binding at the desginer. However when we try to export the data after we do filter, the part which is underlined returns null value and the system crashes. 

protected void WebGrid1_Export(object sender, ISNet.WebUI.WebGrid.ExportEventArgs e)

        {
            e.Table.Rows.Clear();

            DataRowCollection rows = (WebGrid1.DataSourceManager.CurrentDataSource as System.Data.DataView).ToTable().Rows;

            foreach (DataRow row in rows)
            {
                var wgRow = e.Table.CreateRow();

                foreach (WebGridColumn col in e.Table.Columns)
                {
                    if (!col.IsRowChecker)
                    {
                        wgRow.Cells.GetNamedItem(col.Name).Value = row[col.DataMember];
                        wgRow.Cells.GetNamedItem(col.Name).Text = wgRow.Cells.GetNamedItem(col.Name).Value.ToString();
                    }
                }

                e.Table.Rows.Add(wgRow);
            }
        }
All times are GMT -5. The time now is 2:44 AM.
Previous Next