RadGrid & RadToolBar - Object Reference Not Set To An Instance Of An Object

5 posts, 0 answers
  1. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 29 May 2012 Link to this post

    I have a grid that is by default grouped into 1 grouping upon page load.  This is accomplished in the Page_Load event as in the following code.  I had to do this because if using the client-side settings for grouping, when exporting, the group names do not show up in an exported ExcelML format.

            If Not IsPostBack Then
                rgWeightBreaks.MasterTableView.Columns(2).Visible = False
                rgWeightBreaks.MasterTableView.GroupByExpressions.Add(New Telerik.Web.UI.GridGroupByExpression(rgWeightBreaks.MasterTableView.Columns(2)))
    ...

    I have a toolbar that changes the grouping of the grid.  If I don't do anything in the grid such as expand a group, these buttons work flawlessly.  However, if I expand a group and then try to use one of the buttons, I get "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object."

    Here is my client-side code:
            <telerik:RadScriptManager ID="rsmWeightBreaks" runat="server" />
     
            <telerik:RadSkinManager ID="rskmWeightBreaks" runat="server" ShowChooser="false" />
     
            <telerik:RadScriptBlock runat="server" ID="rsbWeightBreaks">
                <script type="text/javascript">
                    function onRequestStart(sender, args) {
                        if (args.get_eventTarget().indexOf("rtbExport") >= 0) {
                            args.set_enableAjax(false);
                            bExporting = false;
                        }
                    }
                </script>
            </telerik:RadScriptBlock>
     
            <telerik:RadAjaxManager ID="ramWeightBreaks" runat="server"
                DefaultLoadingPanelID="ralpWeightBreaks"
                ClientEvents-OnRequestStart="onRequestStart"
                meta:resourcekey="ramWeightBreaksResource1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="rgWeightBreaks">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rgWeightBreaks" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="rtbWeightBreaks">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rtbWeightBreaks" />
                            <telerik:AjaxUpdatedControl ControlID="rgWeightBreaks" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
     
            <telerik:RadAjaxLoadingPanel ID="ralpWeightBreaks" runat="server"
                meta:resourcekey="ralpWeightBreaksResource1"></telerik:RadAjaxLoadingPanel>
     
            <div style="width:800;">
            <asp:Label ID="lblIntroText1" runat="server" Text="Thank you for the opportunity to quote your shipment, please click on the below gateway to view your rates." meta:resourcekey="lblIntroText1" />
            <br /><br />
            <asp:Label ID="lblIntroText2" runat="server" Text="The inland rates displayed below reflect the price per kilogram in US Dollars." meta:resourcekye="lblIntroText2" />
            <br /><br />
            <asp:Label ID="lblFuelSurchargeText1" runat="server" meta:resourcekey="lblFuelSurchargeText1"></asp:Label> <asp:Label ID="lblFuelSurchargeAmount" runat="server" /> <asp:Label ID="lblFuelSurchargeText2" runat="server" meta:resourcekey="lblFuelSurchargeText2" />
            <br /><br />
            <div>
                <asp:Label ID="lblTermsAndConditions" runat="server" meta:resourcekey="lblTermsAndConditionsResource" Text="All quotes are subject to the " /> <asp:HyperLink ID="hlTermsAndConditions" runat="server" meta:resourcekey="hlTermsAndConditionsResource" NavigateUrl="#" Text="Terms & Conditions" />
            </div>
            <br />
            </div>
     
            <telerik:RadTabStrip ID="rtsWeightBreaks" runat="server" Width="802px"
                meta:resourcekey="rtsWeightBreaksResource1" SelectedIndex="0">
                <Tabs>
                    <telerik:RadTab runat="server" Text="US Exports - Inland Rates" Selected="true"
                        meta:resourcekey="RadTabResource1"></telerik:RadTab>
                    <telerik:RadTab runat="server" Text="US Imports - Inland Rates" Selected="true"
                        meta:resourcekey="RadTabResource2"></telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
     
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <telerik:RadToolBar ID="rtbWeightBreaks" runat="server"
                            OnButtonClick="rtbWeightBreaks_ButtonClick"
                            meta:resourcekey="rtbWeightBreaksResource1">
                            <Items>
                                <telerik:RadToolBarButton Text="Gateway View" CommandName="GatewayView"
                                    runat="server" Enabled="false" meta:resourcekey="RadToolBarButtonResource1"></telerik:RadToolBarButton>
                                <telerik:RadToolBarButton Text="Airport View" CommandName="AirportView"
                                    runat="server" meta:resourcekey="RadToolBarButtonResource2"></telerik:RadToolBarButton>
                            </Items>
                        </telerik:RadToolBar>
                    </td>
                    <td>
                        <telerik:RadToolBar ID="rtbExport" runat="server"
                            OnButtonClick="rtbWeightBreaks_ButtonClick"
                            meta:resourcekey="rtbExportResource1">
                            <Items>
                                <telerik:RadToolBarButton Text="Export To Excel" CommandName="ExportToExcel"
                                    runat="server" meta:resourcekey="RadToolBarButtonResource3"></telerik:RadToolBarButton>
                            </Items>
                        </telerik:RadToolBar>
                    </td>
                </tr>
            </table>
     
            <telerik:RadGrid ID="rgWeightBreaks" runat="server" Width="800px"
                CellSpacing="0" GridLines="None" meta:resourcekey="rgWeightBreaksResource1">
                <MasterTableView AutoGenerateColumns="false" GroupsDefaultExpanded="false" GroupLoadMode="Client"
                    DataKeyNames="OriginAirport, DestinationAirport, TariffNumber" ClientDataKeyNames="OriginAirport, DestinationAirport, TariffNumber"
                    UseAllDataFields="true" EnableHeaderContextMenu="true" AllowFilteringByColumn="true">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Origin City" DataField="OrgAirportCity"
                            HeaderStyle-Width="200px" ItemStyle-Width="200px" AllowFiltering="true"
                            meta:resourcekey="GridBoundColumnResource1">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Airport" DataField="OriginAirport"
                            HeaderStyle-Width="50px" ItemStyle-Width="50px" AllowFiltering="true"
                            FilterControlWidth="35px" ShowFilterIcon="false" AutoPostBackOnFilter="true"
                            meta:resourcekey="GridBoundColumnResource2">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="To Gateway" DataField="DestAirportCity"
                            HeaderStyle-Width="175px" ItemStyle-Width="175px" UniqueName="OriginCity"
                            Groupable="true" AllowFiltering="true"
                            meta:resourcekey="GridBoundColumnResource3">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Transit Days" DataField="TransitDays"
                            HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="Right"
                            ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Right" AllowFiltering="false"
                            meta:resourcekey="GridBoundColumnResource4">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Minimum Charge" DataField="MinimumCharge"
                            DataFormatString="{0:C}" HeaderStyle-HorizontalAlign="Right"
                            ItemStyle-HorizontalAlign="Right" AllowFiltering="false"
                            meta:resourcekey="GridBoundColumnResource5">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="45 kgs<br/>(100 LBS)" DataField="BreakOne"
                            DataFormatString="{0:C}" HeaderStyle-HorizontalAlign="Right"
                            ItemStyle-HorizontalAlign="Right" AllowFiltering="false"
                            meta:resourcekey="GridBoundColumnResource6">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="225 kgs<br/>(500 LBS)"
                            DataField="BreakTwo" DataFormatString="{0:C}"
                            HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"
                            AllowFiltering="false" meta:resourcekey="GridBoundColumnResource7">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="450 kgs<br/>(1000 LBS)"
                            DataField="BreakThree" DataFormatString="{0:C}"
                            HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"
                            AllowFiltering="false" meta:resourcekey="GridBoundColumnResource8">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="1350 kgs<br/>(3000 LBS)"
                            DataField="BreakFour" DataFormatString="{0:C}"
                            HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"
                            AllowFiltering="false" meta:resourcekey="GridBoundColumnResource9">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CityAirport" HeaderText="From Airport"
                            UniqueName="CityAirport"
                            Groupable="true" meta:resourcekey="GridBoundColumnResource10" Display="false">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" />
                </MasterTableView>
                <GroupingSettings ShowUnGroupButton="true" />
                <ClientSettings AllowExpandCollapse="true" EnableRowHoverStyle="true" AllowDragToGroup="true">
                    <Selecting AllowRowSelect="true" />
                    <Scrolling UseStaticHeaders="true" AllowScroll="true" ScrollHeight="500px"/>
                    <Resizing AllowColumnResize="true" />
                </ClientSettings>
                <ExportSettings OpenInNewWindow="true" ExportOnlyData="true">
                    <Excel Format="ExcelML" />
                </ExportSettings>
            </telerik:RadGrid>
     
            <telerik:RadToolTip ID="rttTermsAndConditions" runat="server"
                TargetControlID="hlTermsAndConditions" RelativeTo="Element"
                Title="Terms And Conditions" Width="700px" Animation="Slide"
                HideEvent="LeaveTargetAndToolTip"
                meta:resourcekey="rttTermsAndConditionsResource">
                <div style="margin:10px">
                    <ol>
    ...


  2. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 31 May 2012 Link to this post

    Hello Seth,

    The experienced JavaScript error is caused when you have ajax enabled and the server throws exception. In order to resolve your issue you could disable the ajax and see on which line the error occurs. Object reference not set to an instance of an object could be handled with additional condition in your code behind.

    Kind regards,
    Antonio Stoilkov
    the Telerik team
    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 their blog feed now.
  3. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 31 May 2012 Link to this post

    I set EnableAJAX="false" in the RadAjaxManager and I got the attached ASP.NET error page.  I attempted to put breakpoints in all of my code behind and it never even reaches that point.
  4. Chrystal Tyler
    Chrystal  Tyler avatar
    5 posts
    Member since:
    Nov 2007

    Posted 31 May 2012 Link to this post

    I am having the same issue.  All worked fine until I upgraded to the latest version of Ajax RadControls.  I just do not see how to identify what the specific issue is when it never reaches a set of breakpoints.
  5. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 05 Jun 2012 Link to this post

    Hi Chrystal,

    The experienced issue is not common. In order to investigate the issue you could open a formal ticket and attach a sample project demonstrating the unwanted behavior.

    All the best,
    Antonio Stoilkov
    the Telerik team
    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 their blog feed now.
Back to Top