DataGrid template column and null pointer
Posted on 2005-05-08
I was point to the following solution for use when binding a grid to an array list of objects. The objects as you can see people have other types that need to be navigated to get properties. However sometimes these properties are null and when they are my aspx page blows up with an: Object reference not set to an instance of an object. Specifically when a Person does not have an Employer Object. How can I work around this? I wasn't sure how to best script for this. I am not sure really of the nature of the syntax below like the #
This is C#
I tried something simple like this but it wasn't right and would not compile.
<% if (((Person)Container.DataItem).Employer != null )