Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:51:32+00:00 2026-05-17T00:51:32+00:00

I’m using Silverlight 4 on IE 8. I have created a new Silverlight web

  • 0

I’m using Silverlight 4 on IE 8. I have created a new Silverlight web part for SharePoint 2010 that I am using to read 2 external content types. One represents the Invoices in the Chinook database from Code Plex and the other is the lines of each invoice. I am attempting to display the code in a Master-Detail layout using the Telerik Rad GridView control. I have tried this code in several different ways. Here is a general description:
I have 2 objects InvoiceHeader and InvoiceLine.

Invoice header contains a list of InvoiceLines

public List<InvoiceLine> lines { get; set; }

The only way I was able to get this to “work” was to use a foreach and cycle through the returnedInvoices and then use a sub foreach(var invoice in returnedInvoices) and add each line to a list and then adding the list to the current invoice using invoice.lines.Add(new InvoiceLine(line));

Of course the problem was that I could not clear lines using lines.Clear() or all of the lines were cleared in all of the InvoiceHeader objects. Since I could not clear the list each invoice had the following invoices lines added to its own lines. So I created a tracking array of InvoiceHeaders and tried using it to do tracking[x].lines.Add(new InvoiceLine(line)); and I then received the error in my subject for this post. Object reference not set to an instance of an object when trying to add an InvoiceLine to the InvoiceHeader object’s List. I’m not really a developer, so I would appreciate any help you can give me. Currently the code has become crazy, so my apologies for that. I have included the succeededCallback below:

 void succeededCallback(object sender, ClientRequestSucceededEventArgs e)
    {
        this.Dispatcher.BeginInvoke(() =>
            {
                invoices.Clear();
                invoiceLines.Clear();
                int x = 0;
                int y = 0;
                foreach (var inv in returnedInvoices)
                {
                    x++;
                }

                InvoiceHeader[] tracker = new InvoiceHeader[x];

                foreach (var invoice in returnedInvoices)
                {
                    tracker[y] = new InvoiceHeader(invoice);

                     //Get the lines that correspond to this invoice.
                    foreach (var line in returnedLines)
                    {
                        if(line.FieldValues["InvoiceId"].ToString() == invoice.FieldValues["InvoiceId"].ToString())
                        { 
                            //tracker[y].lines.Add(new InvoiceLine(line));
                            /*
                             * If I comment out the line above
                             * I do not get the error, but I also
                             * don't get my detail level.
                             */
                        }

                    }

                    invoices.Add(tracker[y]);
                    if (y < x) { y++; }
                }

                radGridView1234.ItemsSource = invoices;                        
            }
            );
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:51:33+00:00Added an answer on May 17, 2026 at 12:51 am

    When are you initializing lines? Typically, collection properties only have a getter with a private setter when used as an autoproperty.

    public List<InvoiceLine> lines { get; private set; }
    

    You must initialize it as you’re currently calling .Add on a null.

    lines = new List<InvoiceLIne>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.