A retaining device (10) for retaining expansion cards (20) in a chassis (300) includes a retaining member (100) and a locking member (200). An upper positioning protrusion (316) and a lower positioning protrusion (318) are formed on a bent plate (312) of the chassis. The locking member is pivotally attached to the bent plate. A pressing portion (216) is formed on an inner side of the locking member and a notch (206) is defined in an outer side of the locking member. A support portion (126) is formed on the retaining member corresponding to the pressing portion. When the upper positioning protrusion is matched with the notch, the retaining member is put into the chassis. The locking member is pressed until the lower positioning protrusion is matched with the notch, and thus the retaining member is secured to the chassis.