The current year in the campaign is 1075.
The wall was raised in year 0. The raising of the wall began the counting of the current calendar.
Codex Arcanis page 163 wrote:
The Dwarves soon discovered to their horror that they would age rapidly if they had not basked in the blood-red glow every decade or so.
The Campaign Setting says dwarves live to about 350 years
Elebac a Solani Mor dwarf was over five centuries in the year 1025. He felt he was nearing the end of his live in 1025. And he's still alive and in the First City today (1075)
So if you assume the Dwarves bathed in the glow of the Heartstone earlier that year (year 0). Then were trapped, they would have aged normally for about 10 years, then quickly they would have died out.
Gnomes are not sterile, but their looks and social standing in every nation make it so they won't find companionship easily. Giantskeep is the opposite of course, the gnomes were the rock stars of that city as they had sacred blood within them. I would assume they would not have trouble finding a husband or wife.
Plus you can throw in the random "emigration" from a nearby city (Bastion), nation (Haina), or prison (Lordship of Iron) leads to a very stable population, for gnomes to be present when your party gets to Giant's Keep.
Legacy of Damnation give the population as 9839 (humans 98%, gnomes 2%)
I hope this helps.