This is from Bach's Chromatic Fantasie and Fugue:
This would obviously be played D, C#, D. Let's say that there was a C on the same octave later in that measure. Would the C be sharp?
The convention for ornaments is that a sharp or flat will affect only the ornament, and not other notes within the measure. So in your example, any note written in the C space will be played as a C natural - but if there is a second mordent in the same measure, the C in that mordent will also be sharped without needing an additional accidental.
This rule applies only to accidentals over or under the ornament symbol. An ornament that is written within the staff (e.g. a grace note with a sharp) WILL alter any following notes on the same line/space within the measure.
Note (sic) that the sharp sign is not there in reference to the D note, instead it's above it (rather than before it), thus referencing the mordant itself. The target note after the fiddly bit will be a D natural. That sharp defines which actual notes will be played during the mordant. It certainly won't affect anything else in that bar at all, in particular the actual D note itself, and certainly not any subsequent C notes.