object reference not set to an instance of an object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Asprisa
    New Member
    • Oct 2007
    • 30

    object reference not set to an instance of an object

    Hi Guys,

    We have a aspx page on a web server that was created by someone who has now left our company which for some reason just started throwing an error, i have been looking into reasons for about 3 days now and am not getting any where, can any one put me in the right direction?

    The error is:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    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.NullRefe renceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NullReferenceEx ception: Object reference not set to an instance of an object.]
    Navision_sales_ type_details.Pa ge_Load(Object sender, EventArgs e) +101
    System.Web.Util .CalliHelper.Ev entArgFunctionC aller(IntPtr fp, Object o, Object t, EventArgs e) +24
    System.Web.Util .CalliEventHand lerDelegateProx y.Callback(Obje ct sender, EventArgs e) +41
    System.Web.UI.C ontrol.OnLoad(E ventArgs e) +131
    System.Web.UI.C ontrol.LoadRecu rsive() +65
    System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +2427

    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.507 27.3607; ASP.NET Version:2.0.507 27.3082






    The source code to the page being launch is

    Code:
    <%@ page language="C#" autoeventwireup="true" inherits="Navision_SalesInvoiceReport, App_Web_dev_rfop" %>
    
    <!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 runat="server">
        <title>Sales Invoice Report</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div style="text-align: center">
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" BackColor="#336699" BorderStyle="Ridge" Font-Bold="True"
                Font-Names="Arial" ForeColor="#FFFFFF" OnClick="Button1_Click" Text="Export to Excel"
                Width="165px" /><br />
            <br />
            <br />
             
            <asp:GridView ID="GridView1" runat="server"
                AutoGenerateColumns="False" CellPadding="4" DataKeyNames="No_" DataSourceID="SqlDataSource1"
                ForeColor="#333333" GridLines="None" PageSize="20">
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:BoundField DataField="No_" HeaderText="No_" ReadOnly="True" SortExpression="No_" />
                    <asp:BoundField DataField="Sell-to Customer No_" HeaderText="Sell-to Customer No_"
                        SortExpression="Sell-to Customer No_" />
                    <asp:BoundField DataField="Bill-to Customer No_" HeaderText="Bill-to Customer No_"
                        SortExpression="Bill-to Customer No_" />
                    <asp:BoundField DataField="Bill-to Name" HeaderText="Bill-to Name" SortExpression="Bill-to Name" />
                    <asp:BoundField DataField="Ship-to Name" HeaderText="Ship-to Name" SortExpression="Ship-to Name" />
                    <asp:BoundField DataField="Order Date" HeaderText="Order Date" SortExpression="Order Date" />
                    <asp:BoundField DataField="Posting Date" HeaderText="Posting Date" SortExpression="Posting Date" />
                    <asp:BoundField DataField="Shortcut Dimension 1 Code" HeaderText="Shortcut Dimension 1 Code"
                        SortExpression="Shortcut Dimension 1 Code" />
                    <asp:BoundField DataField="Shortcut Dimension 2 Code" HeaderText="Shortcut Dimension 2 Code"
                        SortExpression="Shortcut Dimension 2 Code" />
                    <asp:BoundField DataField="Sell-to Customer Name" HeaderText="Sell-to Customer Name"
                        SortExpression="Sell-to Customer Name" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                    <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                    <asp:BoundField DataField="Unit Price" HeaderText="Unit Price" SortExpression="Unit Price" />
                    <asp:BoundField DataField="Unit Cost (LCY)" HeaderText="Unit Cost (LCY)" SortExpression="Unit Cost (LCY)" />
                    <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
                    <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                    <asp:BoundField DataField="Salesperson Code" HeaderText="Salesperson Code" SortExpression="Salesperson Code" />
                    <asp:BoundField DataField="item_number" HeaderText="item_number" SortExpression="item_number" />
                    <asp:BoundField DataField="Profit Amount" HeaderText="Profit Amount" SortExpression="Profit Amount" />
                    <asp:BoundField DataField="Profit Margin %" HeaderText="Profit Margin %" SortExpression="Profit Margin %" />
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
           <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:navision %>"
                SelectCommand="SELECT [fakecompany Solutions Limited$Sales Invoice Header].No_, [fakecompany Solutions Limited$Sales Invoice Header].[Sell-to Customer No_], [fakecompany Solutions Limited$Sales Invoice Header].[Bill-to Customer No_], [fakecompany Solutions Limited$Sales Invoice Header].[Bill-to Name], [fakecompany Solutions Limited$Sales Invoice Header].[Ship-to Name], [fakecompany Solutions Limited$Sales Invoice Line].Type, CONVERT (varchar(11), [fakecompany Solutions Limited$Sales Invoice Header].[Order Date], 103) AS [Order Date], CONVERT (varchar(11), [fakecompany Solutions Limited$Sales Invoice Header].[Posting Date], 103) AS [Posting Date], [fakecompany Solutions Limited$Sales Invoice Header].[Shortcut Dimension 1 Code], [fakecompany Solutions Limited$Sales Invoice Header].[Shortcut Dimension 2 Code], [fakecompany Solutions Limited$Sales Invoice Header].[Sell-to Customer Name], [fakecompany Solutions Limited$Sales Invoice Line].Description, [fakecompany Solutions Limited$Sales Invoice Line].Quantity, [fakecompany Solutions Limited$Sales Invoice Line].[Unit Price], [fakecompany Solutions Limited$Sales Invoice Line].[Unit Cost (LCY)], [fakecompany Solutions Limited$Sales Invoice Line].Amount, [fakecompany Solutions Limited$Sales Invoice Header].[Salesperson Code], [fakecompany Solutions Limited$Sales Invoice Line].No_ AS item_number, [fakecompany Solutions Limited$Sales Invoice Line].[Profit Amount], [fakecompany Solutions Limited$Sales Invoice Line].[Profit Margin %] FROM [fakecompany Solutions Limited$Sales Invoice Line] INNER JOIN [fakecompany Solutions Limited$Sales Invoice Header] ON [fakecompany Solutions Limited$Sales Invoice Line].[Document No_] = [fakecompany Solutions Limited$Sales Invoice Header].No_ WHERE ([fakecompany Solutions Limited$Sales Invoice Header].[Posting Date] > GETDATE())">
            </asp:SqlDataSource>
        
        </div>
        </form>
    </body>
    </html>
    Sorry that this is a lot of text, but i thought it may help someone point out the problem, Thanks in advance!
    Last edited by Frinavale; Apr 7 '10, 08:08 PM. Reason: Please post code in [code] ... [/code] tags. It makes it easier for us to read your posted code. Added code tags.
  • Blacky
    New Member
    • Jan 2009
    • 40

    #2
    Hi,

    This error might be coz of the improper intialization of the controls in aspx.cs page.So using breakpoint n debugging could help you in sorting this.

    Thanks,
    Blacky

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

      Thanks,
      CroCrew~

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        You know, I don't think that the error is happening in the code you posted.

        If you look at the error message you will see that it occurs in your Page Load event.

        Could you please post the code for your Page Load event so we can see what's going on in the place where the error occurred?

        -Frinny

        Comment

        Working...