When I dryhop with pellets in the keg, I use a very finely woven hops bag, like this:
http://www.northernbrewer.com/shop/nylon-hop-bag-8-x-9-1-4.html
When I dryhop with whole (leaf) hops in the keg, I use a big teaball strainer or a hops bag or whatever. They stay put pretty well.
The pellet hops disintegrate and come right through the teaball strainer and clog up my diptube badly. I speak from experience- it sucked!
I don't tie my bag to anything- I just put it in the keg for the life of the keg. My kegs are kept cold in the kegerator, and it takes longer for the dryhopping to be apparent, but it seems like keeping it cold keeps it from getting any "grassy" off-flavors that others talk about. I've never had that happen.