First, explain the issue you are having clearly and second, post the code that is causing the problem and we will be glad to help.
As for sample code and stuff like that, I think it would be best if you do research on your own as that would be the best way to learn.
HINT: Find the keywords used in the answer and Google it.