The best way to determine heat of solution is to imagine it as a hypothetical two-step process where the ions separate from a crystal to form a gas and then plunge into the water. While this isn't actually what occurs, the change in enthalpy will be the same because enthalpy is a state function.
The amount of heat necessary to turn the ionic compound into a gaseous vapor is equal to the lattice enthalpy of the compound. The lattice enthalpy in turn is equivalent to the sum of the enthalpy of formation plus the enthalpy of atomization plus the enthalpy of ionization for the elements in the ionic compound. By adding the lattice enthalpy to the enthalpy of hydration, the heat released when the gaseous ions plunge into the water, we can find the enthalpy or heat of solution.
Breaking bonds takes energy, while forming bonds releases energy, so when an ionic compound dissolves in water, it takes energy to break the ions apart but energy is released by the ion-dipole bonds the ions form with water molecules. That's why the sum of the enthalpy of hydration and the lattice enthalpy is equivalent to the heat of solution. It's interesting to note that salt (sodium chloride) actually has a positive enthalpy of solution, meaning it absorbs a very small amount of heat when it dissolves. Since the increase in entropy is greater than the heat energy absorbed, however, salt still dissolves spontaneously in water.