Incomplete information: we need to know which line is throwing the NullReferenceException in order to tell precisely where the problem lies.
Obviously, you are using an uninitialized variable (i.e., a variable that has been declared but not initialized) and try to access one of its
non-static method/property/whatever.
Solution:
- Find the line that is throwing the exception from the exception details
- In this line, check that every variable you are using has been correctly initialized (i.e., it is not
null
)
Good luck.
Edit: my guess is that
GlobalContainer.Objects.Bookings[Convert.ToString(e.Parameter)]
does not find any object in the collection matching the parameter => thus bBooking is null => every attempt to access a non-static member of the bBooking variable leads to a NullReferenceException.
But it's just a guess... In that case, the solution could be as simple as enclosing your code in a
if (bBooking != null) {
lblTitle.Text = bBooking.PersonTitle;
}
block.