Mshea's right, don't force it. I'm one of those guys who already have the intire idea in their head usually, but if I don't I let the beat play over and over.
If you use a sample, usually the bassline is already there, you just have to listen to the sample,(listen in between the lines) You can hear things inside the sample to accentuate. (did I spell that right?)
Try to find the key that is closest to the key of the sample, then play it about an octave down. Sometimes it helps to listen to the empty spaces in the beat, the bassline can fit in those spaces sometimes.
I also leave it alone sometimes.
Guys gave alot of good advice here, hope it helps.