Kennis,
I believe the best solution would be customized, because no generalized solution can give you numbers in the right places for all paths that it may be applied to.
You may:
1) Create the path with dashes, then create a copy and lock the original;
2) With the Path Type Tool click the path and write the number, then adjust its position with the Baseline Shift;
3) In the Appearance palette flyout click Add New Fill, drag it beneath the Characters in the main window and change the fill to white (or other background colour);
4) Effect>Convert to Shape>Rectangle, set Relative>Extra suitably;
5) Copy the path type from 4) and drag to new position for each new instance.