Forced, random change of gender or alignment can ONLY be interpreted as a direct, PURE ROLEPLAYING challenge by the adventure designer to the player. It has crap-all to do with anything else about the game. If your character changes gender then (in 3E at least) it has no functional impact upon your characters actions. It's strictly a challenge to then roleplay the character as a person of a different gender. If your character changes alignment it's a different story - but only if the character has alignment restrictions from his class or gear that remain unchanged. Aside from that there is little functional mechanical change if any. It's just a challenge (even greater than gender I'd say) to then roleplay from that point given the instant, new alignment.
Now, whether he thought about it or not (generally not) the DM has tacitly agreed to present this ROLEPLAYING challenge to the player. This is a sudden and DRASTIC slap in the face to however the game may have been proceeding to this point. What it comes down to is that the PLAYER DID NOT SIGN UP FOR THIS. They player created the character he CREATED, NOT the character that has suddenly been FORCED upon him regardless of what similarities this new one has to the old one. Players need not and MUST NOT be FORCED to live with this. It is entirely possible that the player is not up to the challenge or simply doesn't want to ACCEPT the challenge.
Any DM who insists that a player accept and play out this roleplaying challenge is a jerk. There's just no other way of putting it. It is the PLAYERS choice to accept this challenge and the DM's OBLIGATION to allow the player the relatively painless opportunity to reverse this kind of change. It is NO different - NONE - than if the DM tore your character sheet out of your hands, handed you a sheet for a character of an entirely different class, race, gear, etc. and said, "You WILL now play this character instead whether you want to or not."
In such modules these things are never PRESENTED that way of course. They're just amusing little slaps to the players - but like any excessive practical joke or even a simple pie-in-the-face it STOPS being funny when it STARTS being YOU. Frequently I've found that players would even prefer to have a character permanently killed than to be FORCED to such an ignominious end as it so easily destroys ALL desire to continue to play that character. Why wouldn't it since it is NOT the character you created, played and built up over time?
What needs to happen then is that you need to present these roleplaying facts-of-life to the DM. If the player is willing to accept the challenge then by gods the DM had better have some suitable rewards coming to the player eventually for playing through it. If the player is NOT willing to accept the challenge, however, then the DM should provide some means of smoothly resuming the characters former incarnation with a minimum of fuss and bother.
The SOLE exception to all of the above is if there was AMPLE warning about these kinds of possibilities (and we're not just talking about cryptic riddles the player never saw or a statement like, "Gosh, you'd better make THIS save!"), the player made a CHOICE to accept the risks, and now is faced with living with the consequences of taking that risk.
Aside from all that I'd have to know a LOT more about the character, the party, and the game events from character creation to present to be able to meaningfully suggest how the player might deal with it IF he chose to.
I really REALLY despise screwing with PC's this way. Even though I once engaged in this kind of crap myself I find it difficult to be sympathetic in ANY way to any DM who allows it.