I have a problem with radiobutton. Application uses it when reading data from the database. Reads the user's gender. This function works when a user is logged on and selects the appropriate button. The first time you read correctly, but the second program returns an exception NullReferenceException was unhandled.
C#
if (napis.ItemArray.GetValue(5).ToString() == "Mężczyzna")
{
MezczyznaRadioButton2.IsChecked = true;
KobietaRadioButton2.IsChecked = false;
}
else
{
KobietaRadioButton2.IsChecked = true;
MezczyznaRadioButton2.IsChecked = false;
}