Um... Depends on what they did. Since I'm not 100% sure on what you can be detained on, I think that if it's something minor then yes. But not the criminally insane or inmates like that, since I think they'd vote for extremist parties, just to punish.
i dont think any of them should be allowed to vote!!! even if they stole an apple. becasue the thing is, they have took away that persons right to have the apple, of whom they stole it from, so the prisoner should have rights taken away from them.