Electricity is conducted when charges move from one place to another. In solid ionic compounds, the ions are attracted to form a lattice and are unable to move freely and hence, they cannot conduct electricity.
However, if you melt an ionic compound or dissolve it in water, these ions are now free to move around because the weak ionic bonds are now broken. The ions in these conditions are free to move and carry electrons between the anode and the cathode. As a result, the solution can be made to conduct electricity.