radgrid Export to PDF commanditem and ajax

4 posts, 0 answers
  1. Greg
    Greg avatar
    17 posts
    Member since:
    Oct 2010

    Posted 03 Nov 2010 Link to this post


    I have a following code in my radgrid:

    <CommandItemTemplate>
        <asp:LinkButton ID="ExportToPdfButton" runat="server" CommandName="ExportToPdf" CssClass="pdfButton" ></asp:LinkButton>
    </CommandItemTemplate>

    The radgrid is ajaxafied with a RadAjaxManager.

    Use ItemCreated in I call RegisterPostBackControl so that when I click the PDF button it doesn't use ajax and pops up my PDF.

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
            If TypeOf e.Item Is GridCommandItem Then
                Dim btn As LinkButton = e.Item.FindControl("ExportToPdfButton")
                If Not btn Is Nothing Then
                    RadScriptManager.GetCurrent(Page).RegisterPostBackControl(btn)
                End If
            End If
    End Sub

    This works fine the first time my page loads. I click the PDF, it opens up... all good. 
    However, I have a series of combo boxes that are wired in the RadAjaxManager to rebind the grid when changed. When the radgrid gets changed through an ajax postback, and I click the PDF button, it then causes an ajax postback and the commanditem template disappears entirely, and of course.. the PDF is not created.

    Any idea how I can make sure the PDF button always does a regular postback?
  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 03 Nov 2010 Link to this post

    Hello Greg,

    I suggest that you avoid the RegisterPostBackControl workaround since it won't work in some scenarios. Instead, I recommend that you use the approach depicted in the following link:
    Export from ajaxified grid

    Regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Greg
    Greg avatar
    17 posts
    Member since:
    Oct 2010

    Posted 03 Nov 2010 Link to this post

    Thanks. However, it now pops the PDF, but still starts the loading panels which show my "Loading..." image... but never complete.

    So when I close or cancel the pdf, I can't see my grid anymore and have to refresh the page, or trigger an ajax postback with one of my combo boxes to get it to reappear.
  5. Greg
    Greg avatar
    17 posts
    Member since:
    Oct 2010

    Posted 03 Nov 2010 Link to this post

    Nevermind... had my radajaxmanager improperly setup...
Back to Top