Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • chris vdP 13 posts 35 karma points
    Aug 22, 2011 @ 23:14
    chris vdP
    0

    FindControl returns object reference error

    I have an asp.net control that work fine outside of Umbraco. When I add control to umbraco I get the follow error

     

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    Source Error: 
    Line 690:                    totalAmount += subTotal;
    Line 691:                }
    Line 692:                ((Literal)this.grvPurchases.FindControl("ltrlTotalGST")).Text = "$" + String.Format("{0:0.00}", totalGst);
    Line 693:                ((Literal)this.grvPurchases.FindControl("ltrlTotalPay")).Text = "$" + String.Format("{0:0.00}", totalAmount);
    Line 694:

    Source File: C:\Web Projects\EventRegistration\EventRegistration\controls\eventRegistration.ascx.cs    Line: 692 
    Stack Trace: 
    [NullReferenceException: Object reference not set to an instance of an object.]
       EventRegistration.controls.eventRegistration.ListRegistrants() in C:\Web Projects\EventRegistration\EventRegistration\controls\eventRegistration.ascx.cs:692
       EventRegistration.controls.eventRegistration.AddToSessionRegistration(Person newRegistrant) in C:\Web Projects\EventRegistration\EventRegistration\controls\eventRegistration.ascx.cs:574
       EventRegistration.controls.eventRegistration.btnSaveReg_Click(Object sender, EventArgs e) in C:\Web Projects\EventRegistration\EventRegistration\controls\eventRegistration.ascx.cs:1168
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.2
    25

    I get it on the following line of code

     ((Literal)this.grvPurchases.FindControl("ltrlTotalGST")).Text = "$" + String.Format("{0:0.00}", totalGst);

    As I said the code works outside of umbraco so the literal exists and is in grvPurchases. The event is fired on an on button click

     

Please Sign in or register to post replies

Write your reply to:

Draft