this was actually a topic in hsc biology and has to do with the natural concentration gradients in environments.
More simply, in freshwater environments the cell fluids in fish are more concentrated (with electolytes/salts) then the surrounding water therefore they tend to gain water by osmosis, as water will move from an area of high conc (i.e low in solutes eg salt) to an area of low conc (one which is high in solutes). therefore freshwater fish dont "drink" and they excrete large amounts of dilute urine and actively absorb salts through their gills to maintain this concentration gradient.
in marine environments organisms have a lower internal salt conc then the area around them and they must have adaptations to prevent excessive water loss. they constantly "drink" water and the gills excrete salt. they also produce a very conc urine. therefore the water lost by excretion is less then the water taken in by drinking and they remain hydrated.
they are known as osmoregulators:
in brief: freshwater fish excrete water and absorb salts
saltwater fish: conserve water and excrete salt.
sharks and rays: osmoconformers (their internal concentration changes with external environment)
sorry for the long response but hope it answers the question.
cheers pk.