It is not much of a problem. You should make sure that they don't drink lots of fluids before bed. You can also try waking them in the middle of the night to use the toilet so that they would develop...
For people who are older than a kindergartener, a visit to the doctor for advice is in order. There are biofeedback measures and, for some, medication that may help. It just depends on the physiology...
There are many causes of bed wetting/wetting your pants- most children/young adults who do this are completely normal and therefore, problem can be remedied easily. Sometimes though there are other...