I've got the following coding where I am trying to step through a couple of if
statements, but I've got a problem with setting my label's content to 0
;
private void UnderRunBumper()
{
lblGVMAmount.Content = 0; //Issue here
if (Convert.ToInt32(txtExternalLength.Text) >= 6000)
lblUnderRunBumper.Content = "Under-Run Bumper";
else if (Convert.ToInt32(lblGVMAmount.Content.ToString()) >= 8000)
lblUnderRunBumper.Content = "Under-Run Bumper";
else if (cmbBodyType.SelectedIndex == 6 || cmbBodyType.SelectedIndex == 7 || cmbBodyType.SelectedIndex == 8 || cmbBodyType.SelectedIndex == 9 || cmbBodyType.SelectedIndex == 10)
lblUnderRunBumper.Content = "Under-Run Bumper";
else lblUnderRunBumper.Content = "";
}
I get the error:
Object reference not set to an instance of an object.
I don't understand. Why can't I set my label's value to 0?