Again, this is where Jedi training basically boils down to 'feel the negative, but don't let it control you'. You're inevitably going to feel grief at loss - but a Jedi trains to learn to detach from that grief, to not make it personal.
'Possession is forbidden', to quote Anakin at Padme - that possession makes things personal, and making something personal intensifies the emotion. Detaching from personal relationships of all kinds, understanding that death is natural eventually anyway, that sort of thinking, makes it so that loss and grief and anger and what have you aren't going to affect you so much on an individual level. Thus, you avoid the Dark Side in that way.