How many valence electrons do elements in the d block have?
The simplest answer is: d-block elements have number of valence electrons equal to their group number, which is equal to the number of electrons in the "valence shell". This works if you are using the definition of valence shell to be the outermost shell.

But it is wrong to apply the concept to determine the valency of the element, because that varies with the compound it is present in. For example, iron can show two valencies, $2$ and $3$ in the compunds iron(II) sulphate ($\ce{FeSO4}$) and iron(III) sulphate ($\ce{Fe2(SO4)3}$) respectively. But from the above definition, iron has $8$ valence electrons.

As a matter of fact, this applies even to many elements outside d-block too, for example chlorine typically shows a valency of ($-1$) in compunds like $\ce{NaCl}$, but it can also show a different valency (more appropriately, oxidation state) in ions like perchlorate anion ($\ce{ClO4^-}$), where its valency is $\mathbf 7$ (while the oxidation state is $\mathbf{+7}$, notice the difference that there is no plus or minus sign in valency).