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

Object Reference not set to an instance of an object

5 Answers 673 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeevan
Top achievements
Rank 1
Jeevan asked on 14 May 2013, 01:01 PM
Hi,
We are getting the below error in one of the environment, we are using RadGridControl.
Below is the stacktrace, any help would be appreciated.
Thanks.
[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.PreControlToAjaxify.Render(HtmlTextWriter writer) +113
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +306
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +47
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +245
   System.Web.UI.Page.Render(HtmlTextWriter writer) +39
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +50
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +666
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
   System.Web.UI.Page.Render(HtmlTextWriter writer) +39
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4942

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 May 2013, 01:24 PM
Hi,

Can you specify the scenario in which you are the error. Please provide the code so that i can replicate.

Thanks,
Princy.
0
Jeevan
Top achievements
Rank 1
answered on 15 May 2013, 10:33 AM
Hi Princy,
The issue that we are facing is specific to an environment, part of trouble shooting the actual issue, we have created the below test page, it doesn't have any code behind or binding logic, we are just using the RadGrid control in the aspx page. This page loads fine in the Dev box but getting the mentioned error in one of the environment.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TRADSample.WebForm1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head id="Head1" runat="server">
  <title>TEST</title>
    <style type="text/css">
        div.log {
            border: silver 1px solid; background-color: white; padding: 3px 10px 3px 10px;
        }
        div.log .left {
            float: left; font-weight: bold; font-size: 125%;
        }
        div.log .right {
            float: right; font-weight: bold;
        }
        div.log .text {
            overflow:auto; max-height: 200px; width: 100%; padding: 0px 10px 0px 0px;
        }
    </style>
</head>
<body>
    <form id="pageActivitySummary" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager" />
        <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" DefaultLoadingPanelID="LoadingPanel">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgdActivitySummary">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgdActivitySummary" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>
        <h1><asp:Label ID="lblActivity" runat="server"></asp:Label></h1>
            <telerik:RadGrid ID="rgdSummary" runat="server" DataMember="ActivitySummary" AllowSorting="false" ShowHeader="false" BorderStyle="None">
            <MasterTableView DataKeyNames="ActivityLogID">
                <ItemStyle BackColor="#EEF0F6" ForeColor="#333333" />
                <AlternatingItemStyle BackColor="#EEF0F6" ForeColor="#333333" />
                <SortExpressions>
                   <telerik:GridSortExpression FieldName="CreatedOn" SortOrder="Descending"></telerik:GridSortExpression>
                </SortExpressions>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="ActivityLog" UniqueName="ActivityLog">
                        <ItemTemplate>
                           <div class="log">
                                <span class="left">
                                    <%# String.Format("{0:MMM dd yyyy HH:mm} - {1}", DataBinder.Eval(Container.DataItem, "CreatedOn"), DataBinder.Eval(Container.DataItem, "LogType"))%>
                                </span>
                                <span class="right">                                 
     
                                <%if (SolType == 0) {%>                               
                                 
                                <%# string.Format("CreatedBy" + " {0} | " + "PerformedBy" + " {1}<br /> <br />", DataBinder.Eval(Container.DataItem, "CreatedBy"), DataBinder.Eval(Container.DataItem, "PerformedBy"))%>
                                 
                                <% }  else {%>                               
                                <%# string.Format("CreatedBy" + " {0} | " + "PerformedBy"+ " {1}<br />" + "BillableTimeAS"+ " {2}", DataBinder.Eval(Container.DataItem, "CreatedBy"), DataBinder.Eval(Container.DataItem, "PerformedBy"), Convert.ToInt32(DataBinder.Eval(Container.DataItem, "BillableMinutes")))%>
                                <% } %>
                            
                                </span>
                                <div class="text"><%# DataBinder.Eval(Container.DataItem, "LogText").ToString().Replace("\n", "<br />") %></div>
                           </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
         </telerik:RadGrid>
    </form>
</body>
</html>
0
Jeevan
Top achievements
Rank 1
answered on 15 May 2013, 10:34 AM
Having trouble providing the code in this forum, tried couple of times to post the code but some reason not getting displayed here.

The issue that we are facing is specific to one particular environment. Is there anything that I have to check like permissions or placing/registering the telerik controls dll in GAC etc.

The project is in VS 2012 also tested with VS 2010 and framework 4.0

I feel it may not be with the code because it is working fine in other environments.

I have don't have experience working with Telerik controls earlier. Any help would be appreciated.

Thanks.
0
Jeevan
Top achievements
Rank 1
answered on 15 May 2013, 10:35 AM
Having trouble providing the code in this forum, tried couple of times to post the code but some reason not getting displayed here.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TRADSample.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>TEST</title>

<style type="text/css">

div.log {

border: silver 1px solid; background-color: white; padding: 3px 10px 3px 10px;

}

div.log .left {

float: left; font-weight: bold; font-size: 125%;

}

div.log .right {

float: right; font-weight: bold;

}

div.log .text {

overflow:auto; max-height: 200px; width: 100%; padding: 0px 10px 0px 0px;

}

</style>

</head>

<body>

<form id="pageActivitySummary" runat="server">

<telerik:RadScriptManager runat="server" ID="RadScriptManager" />

<telerik:RadAjaxManager ID="RadAjaxManager" runat="server" DefaultLoadingPanelID="LoadingPanel">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="rgdActivitySummary">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="rgdActivitySummary" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>

<h1><asp:Label ID="lblActivity" runat="server"></asp:Label></h1>

<telerik:RadGrid ID="rgdSummary" runat="server" DataMember="ActivitySummary" AllowSorting="false" ShowHeader="false" BorderStyle="None">

<MasterTableView DataKeyNames="ActivityLogID">

<ItemStyle BackColor="#EEF0F6" ForeColor="#333333" />

<AlternatingItemStyle BackColor="#EEF0F6" ForeColor="#333333" />

<SortExpressions>

<telerik:GridSortExpression FieldName="CreatedOn" SortOrder="Descending"></telerik:GridSortExpression>

</SortExpressions>

<Columns>

<telerik:GridTemplateColumn HeaderText="ActivityLog" UniqueName="ActivityLog">

<ItemTemplate>

<div class="log">

<span class="left">

<%# String.Format("{0:MMM dd yyyy HH:mm} - {1}", DataBinder.Eval(Container.DataItem, "CreatedOn"), DataBinder.Eval(Container.DataItem, "LogType"))%>

</span>

<span class="right">

<%if (SolType == 0) {%>

<%# string.Format("CreatedBy" + " {0} | " + "PerformedBy" + " {1}<br /> <br />", DataBinder.Eval(Container.DataItem, "CreatedBy"), DataBinder.Eval(Container.DataItem, "PerformedBy"))%>

<% } else {%>

<%# string.Format("CreatedBy" + " {0} | " + "PerformedBy"+ " {1}<br />" + "BillableTimeAS"+ " {2}", DataBinder.Eval(Container.DataItem, "CreatedBy"), DataBinder.Eval(Container.DataItem, "PerformedBy"), Convert.ToInt32(DataBinder.Eval(Container.DataItem, "BillableMinutes")))%>

<% } %>

</span>

<div class="text"><%# DataBinder.Eval(Container.DataItem, "LogText").ToString().Replace("\n", "<br />") %></div>

</div>

</ItemTemplate>

</telerik:GridTemplateColumn>

</Columns>

</MasterTableView>

</telerik:RadGrid>

</form>

</body>

</html>

0
Andrey
Telerik team
answered on 20 May 2013, 07:22 AM
Hello,

Most probably the problem comes from the IDs of the RadScriptManager and RadAjaxManager controls you have set. The ID of these controls is the same as the name of the control class. In this case when you write in the code editor "RadScriptManager" to what are you referring to the class or to the instance? How the compiler should know?

Try to add one digit in the end of the IDs and check whether the issue would still replicate.

Kind regards,
Andrey
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.
Tags
Grid
Asked by
Jeevan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeevan
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or