Prefrontal cortex (PFC) has been suggested to play an important role in executive cognitive functions, participating in planning and controlling behaviour. The results of several recent electrophysiological studies indicate that PFC might be involved not only in the active maintenance of information but in doing so in a context- or task-dependent manner. In a delayed-match-to-sample paradigm, recordings from neurons in the PFC showed their ability to selectively represent information, which is needed for task completion, suggesting that task-irrelevant information does not access working memory. We present a neurodynamical computational model of a part of the PFC to account for the selective representation of information in working memory. We show that a network of biological realistic integrate-and-fire excitatory and inhibitory neurons, implementing the mechanisms of local or modular biased-competition, which is transmitted through cooperation to different subsets of neuronal pools, can explain the formation of selective context-dependent working memory. The modes of operation of the network are characterized and the corresponding parameter settings revealed. Modular competition and cooperation might constitute general mechanisms for implementing context-dependent formation of working memory.