ExportOnlyData="true" causes null reference exception

3 posts, 0 answers
  1. Brent
    Brent avatar
    14 posts
    Member since:
    Apr 2008

    Posted 20 May 2010 Link to this post

    I am encountering a null reference exception when I set ExportOnlyData="true" and try to export to any format.  If I set ExportOnlyData="false", everything works fine.

    Here are the exception details:
    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Web.UI.RadAjaxControl.OnPagePreRenderComplete(Object sender, EventArgs e) +116
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +11039453
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3671

    Here is my markup:
    <telerik:RadGrid ID="grdResults" Visible="true" runat="server" Skin="WebBlue" AutoGenerateColumns="false" 
        PageSize="20" AllowPaging="true" AllowSorting="true" OnItemCommand="grdResults_ItemCommand" 
        OnNeedDataSource="grdResults_NeedDataSource"
        <ExportSettings FileName="EmployeeSearchResults" ExportOnlyData="true"
        </ExportSettings> 
        <PagerStyle Mode="NumericPages" HorizontalAlign="Center" VerticalAlign="Top" AlwaysVisible="true" 
            Position="Bottom"></PagerStyle> 
        <MasterTableView DataKeyNames="UserId" CommandItemDisplay="Top"
        <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false"  ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true" /> 
            <Columns> 
                <telerik:GridTemplateColumn> 
                    <ItemTemplate> 
                        <telerik:RadAjaxPanel runat="server"
                            <asp:CheckBox ID="chk" runat="server" Checked='<%# Eval("Selected") %>' AutoPostBack="true" OnCheckedChanged="chk_CheckedChanged" /> 
                            <asp:HiddenField ID="hdn" runat="server" Value=<%# Eval("UserId") %> /> 
                        </telerik:RadAjaxPanel> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn SortExpression="EmployeeId" DataField="EmployeeId" HeaderText="Employee ID"
                </telerik:GridBoundColumn> 
                <telerik:GridButtonColumn ButtonType="LinkButton" DataTextField="UserName" HeaderText="Name" 
                    SortExpression="UserName" CommandName="UserProfile"
                </telerik:GridButtonColumn> 
                <telerik:GridBoundColumn SortExpression="Title" DataField="Title" HeaderText="Title"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn SortExpression="CompanyName" DataField="CompanyName" HeaderText="Org / Org Unit"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn SortExpression="ManagerName" DataField="ManagerName" HeaderText="Manager"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn SortExpression="EmailAddress" DataField="EmailAddress" HeaderText="Email Address"
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 


    I am using advanced databinding for my datasource, but I have noticed that the NeedsDataSource event never fires when I try to export only data:

            protected void grdResults_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
            { 
                EmployeeSearchCriteriaDTO criteria = SessionManager.SM.EmployeeSearchCriteria; 
     
                if (criteria != null
                { 
                    IList<EmployeeSearchResultDTO> temp = EmployeeSearchManager.Query2(criteria); 
     
                    if (SessionManager.SM.ComparisonUserIDs != null
                    { 
                        foreach (int id in SessionManager.SM.ComparisonUserIDs) 
                        { 
                            EmployeeSearchResultDTO user = temp.FirstOrDefault(r => r.UserId == id); 
                            if (user != null
                                user.Selected = true
                        } 
                    } 
                    grdResults.DataSource = temp; 
                } 
            } 

    Any ideas?












  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 26 May 2010 Link to this post

    Hello Brent,

    Please try to set RestoreOriginalRenderDelegate to false.
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" RestoreOriginalRenderDelegate="false" runat="server">
        <asp:CheckBox ID="chk" runat="server" Checked='<%# Eval("Selected") %>' AutoPostBack="true" />
        <asp:HiddenField ID="hdn" runat="server" Value='<%# Eval("UserId") %>' />
    </telerik:RadAjaxPanel>

    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. Brent
    Brent avatar
    14 posts
    Member since:
    Apr 2008

    Posted 26 May 2010 Link to this post

    That was it!  Thanks so much!
Back to Top