Your situation hasn't happened to me, but I would check the key switch. The rear of the key switch has a semicircle of wire taps protruding from it. Not all of these taps are associated with the instrumentation, but without knowing which, I'd inspect them all. Check all the wires for suspect, or loose crimp ring connectors. And like battery connectors, these points will corrode and oxidize. One at a time, back the nuts off and verify the surfaces on the connectors are bright clean metal. The space is very tight in there, so disconnect the battery first.
Also on my 2000 X22, mounted directly above the key switch on the belly of the upper dash is a module (I believe associated with the DECC). On it is a ground node; a place where several 'commons' (black wires associated with the negative side of the battery) are bonded together. Make sure all the wires and connections look healthy here as well. In all cases, be careful not to twist the screw-type wire taps off, should the nut be over-torqued or rusted on there.
Good luck,
-WNF-