A new compound Bragg grating structure with periodic nonlinearity and gain is presented. It works as a DFB laser structure that could be switched between two resonance frequencies. A mathematical model has been developed and used to investigate the structure. The laser can be switched between two resonance frequencies by a triggering optical pulse. A numerical simulation of the switching dynamics in the time domain is described. At one of the frequencies, the structure is found to have a self-pulsing behavior.