This is a migrated thread and some comments may be shown as answers.

ExportSettings.IgnorePaging removes paging for web control after postback

3 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JD
Top achievements
Rank 1
JD asked on 03 Oct 2013, 05:39 PM
Hi,

When i set 
this.RadGrid1.ExportSettings.IgnorePaging = true;

the export works as expected, exporting all the data but the web control no longer pages on subsequent postbacks - it just shows all the records.  The initial postback is ok (posting back on the Export button click) but then, for instance if I click "next page" on the grid, paging is removed and all records are shown.

I need to ONLY affect the export, not the web control.  Incidentally, hiding columns results in the same behavior (columns are gone in subsequent postbacks), even though I re-show the columns during the _GridExporting event.  

Thanks,
JD

EDIT - BTW, I am using Advanced data binding.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 04 Oct 2013, 05:48 AM
Hi ,

Please try the below sample code snippet that shows exporting to excel.If this doesn't help,please provide your full code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView DataKeyNames="CustomerID">
    </MasterTableView>
</telerik:RadGrid>
<asp:Button ID="Button1" runat="server" Text="Export To Excel" OnClick="Button1_Click" />

C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        String ConnString = ConfigurationManager.ConnectionStrings["Northwind_newConnectionString3"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address FROM Customers", conn);
 
        DataTable myDataTable = new DataTable();
 
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
 
        RadGrid1.DataSource = myDataTable;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.GetColumn("CompanyName").Visible = false;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.MasterTableView.ExportToExcel();
    }

Thanks,
Shinu
0
JD
Top achievements
Rank 1
answered on 09 Oct 2013, 11:19 PM
The snippet didn't work, but what I found was that the base class of the user control was saving the ViewState to the database.  I walked through this process and as far as I could tell the data is the exact same coming out of the database as going in, but for some reason it breaks the RadGrid.  The solution was simply to not persist the ViewState for the RadGrid page.

This looks very similar to another issue where the guy found he had some framework 1.1 code in a base class, but my base class is framework 4.0.  

In any case, there is a workaround and I will post here if I get a chance to dig deeper into why persisting the ViewState doesn't play nice.

Thanks for your help, though!
JD
0
Kostadin
Telerik team
answered on 14 Oct 2013, 10:08 AM
Hello JD,

Could you please send us your code declaration and the related code behind in order to investigate the issue further?

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
JD
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
JD
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or