In this work, we investigated nonlinear-optical properties in lyotropic ionic liquid crystals (LILC) of potassium caprilate doped with electrochromic impurities (viologens). It is known that after applying a direct electric field to the LILC-viologen cells colouration of samples is observed. Dynamic grating recording under the action of nanosecond pulse laser radiation was obtained for the coloured samples. We analyzed the origin of the optical nonlinearity in the investigated materials taking into account their electrochemical and electrooptical properties. To explain grating recording in LILC doped with viologens, we proposed the mechanism of photoconversion in viologen molecules.