I am trying to fill a datagrid (called dgDeelnemers) with the data from my databank, which I get using the following LINQ method.
[OperationContract]
public IEnumerable<Inschrijvingen> getInschrijvingen()
{
var query = (from p in dc.Inschrijvingens select p);
IEnumerable<Inschrijvingen> i = query;
return i;
}
And then I assign the data to my datagrid in the view using the following code.
public partial class Deelnemers : UserControl
{
public Deelnemers()
{
InschrijvingenServiceClient client = new InschrijvingenServiceClient();
client.getInschrijvingenCompleted += new EventHandler<getInschrijvingenCompletedEventArgs>(client_getInschrijvingenCompleted);
client.getInschrijvingenAsync();
}
void client_getInschrijvingenCompleted(object sender, getInschrijvingenCompletedEventArgs e)
{
if (e.Error != null)
lblDeelnemers.Content = e.Error.ToString();
else
dgDeelnemers.ItemsSource = e.Result;
}
}
But when I navigate to the page I get the following error:
Object reference not set to an instance of an object. at
OndernemersAward.Views.Deelnemers.client_getInschrijvingenCompleted(Object
sender, getInschrijvingenCompletedEventArgs e) at
OndernemersAward.InschrijvingenServiceReference.InschrijvingenServiceClient.OngetInschrijvingenCompleted(Object
state)
I’m not sure what’s causing this, but the return value of ‘i’ I think is correct.

Thank you for taking your time to read this and help me, I greatly appreciate it!
Thomas
You don’t have InitializeComponent()
(taken from my comment) 🙂