This tutorial explains how to do an attached waistband with enclosed elastic. I use this technique on shorts and jeans for my boys.
Step 1. Sew the waistband piece into a circle, press seam open. Sew the elastic into a circle. I overlap the elastic 1/4" and zigzag, making sure to backstitch. You will have to determine how much elastic to use based on how much recovery it has and the kind of fabric you're using. I use pretty firm elastic so I just cut the elastic the length of my child's waist measurement. If your elastic has less recovery you will need to use less.
Step 2. Turn the pants right side out and pin the waistband piece inside the pants, with the waistband piece's right side facing the pants wrong side. For some reason my waistband pieces don't always fit quite right, I had to unpin it and sew it a bit smaller before it was the right size on this pair of pants.
Step 3. Sew the waistband to the pants. I tried to keep this seam at about 1/4"-3/8".
Step 4. Fold the waistband piece up and press. Press the seam allowances towards the waistband.
Step 5. I don't know if my picture shows this well enough but I'll try to explain. For this step you will be topstitching the waistband down on the right side of the pants, so change to topstitching thread. (I use a different machine to topstitch, my more heavy duty, older machine.)
Turn the pants wrong side out. Place the elastic on the waistband and fold the waistband down over the elastic. Fold the edge of the waistband under about 1/4" (you can press this first, it might be helpful, but I usually don't.) Make sure the folded waistband edge is past the edge of the elastic and start sewing. You will need to make the folds and adjust the position of the pants as you sew. Take your time.
Step 6. Just keep going. As you sew you will need to pull the fabric from the back around to the front, since you will be sewing the circle. Another thing that will help is to adjust the fabric and elastic so the waistband is starting to get gathered.
Step 7. When you get to the last 1/3 or 1/4 of this seam, you will need to use both hands to stretch the elastic (within the waistband casing) while you sew. You can adjust the waistband and then stretch and sew a bit, and then adjust again and sew again.
Finished! You can shrink the elastic down a with some steam from your iron. It will also likely shrink down a bit after being washed and dried. I don't sew through the elastic or do anything else to make sure it won't twist in the waistband, but I haven't had any problems with it twisting in denim fabric.
Please let me know if you have questions or if something isn't clear.