Its bloat and its horrible. I have a betta who has it right now. Sometimes it starts as simply constipation which can be relieved by feeding peas and adding epsom salts to the water. Sometimes its a bacterial infection. Its quite sad. Water quality is also very important as stated above. Clean water is the first defense - frequent water changes are important and a heated and filtered tank will also contribute to a bettas overall health and quality of life.
My betta was in a filtered and heated tank. His food was soaked before fed to him to minimize the risk of bloat, and he was fed as much of a pea as he would eat once a week. yet he still developed bloat. I haven't found the cause for my guys problem, but I'm keeping him comfortable since all attempts at a cure (epsom salts, feeding additional peas along with antibacterial food) have failed.
I'm sorry for your loss.