There are a number of different causes of bladder spasms. The cramping pain could be due to something as simple as your diet or a medication that you are taking, or it could be associated with changes in blood supply and function of the nerves controlling the bladder.
However, bladder spasms may be the result of an infection or a recent surgery, or they may occur if you have nerve or muscle damage. So it's important to see a doctor to determine the cause.
In some cases, your doctor may not be able to identify the cause. When this happens, the condition is called idiopathic bladder spasms.
Some common causes of bladder spasms are: