The essential requirement for conducting electricity is presence of free electrons or mobile/free ions.
Sodium chloride in solid state are closely packed by the strong electrostatic force of attraction and the ions are immobile. Therefore as there are no mobile ions conduction of electricity is not possible
But Sodium chloride in solution ionizes to form sodium and chlorine ions,these ions are responsible for conducting electricity.