protected void EditForm_OnItemValidation(object sender, ref string errorMessage)
    {
        FormEngineUserControl ctrl = sender as FormEngineUserControl;

        // Checking countryselector if some country was selected
        if ((ctrl != null) && (ctrl.FieldInfo.Name == "AddressCountryID"))
        {
            int countryId = ValidationHelper.GetInteger(ctrl.Value, 0);

            if (countryId == 0)
            {
                errorMessage = GetString("basicform.erroremptyvalue");
            }

            // If country has states, check if some state was selected
            DataSet states = StateInfoProvider.GetStates("CountryID = " + countryId, "CountryID", 1, "CountryID");

            if (!DataHelper.DataSourceIsEmpty(states))
            {
                object[,] stateObj = ctrl.GetOtherValues();

                if ((stateObj == null) || (stateObj[0, 1] == null))
                {
                    errorMessage = GetString("com.address.nostate");
                }
            }
        }
    }