What to do when an advisor takes credit for a grant proposal?
As far as I know, a grant is given almost always to a PI (principal investigator, i.e. head of the lab). Sometimes postdocs can also be listed as PIs, but I don't remember seeing a grad student as a PI on a grant. So even if technically you wrote the grant proposal, the PI will receive the grant.

This means that he is the one that can write in his CV that he got the grant, and you can write that you wrote the proposal. You cannot write that you are the one that got the grant if you are not listed on it, regardless of whether you wrote the grant proposal.

In this sense, a grant is different than a research paper, where you get credit according to your contribution. A grant is given not as a prize for writing a good proposal, but as funding of specific future work executed by a specific person/lab. I am not sure what the guidelines are for grant proposal writing, but I would not be surprised if this is considered ok in terms of the guidelines. Of course I am assuming your advisor read it thoroughly and thought it is a good research plan.

Also, it is very possible that your PI actually did have a major contribution to getting the grant. The funding agency takes into considerations several factors such as the grant proposal but also the PI's record.

Having said all this, you should definitely write in your CV that you wrote a successful grant proposal by yourself (you can consult with your advisor on how to write this in the most impactful way).

Disclaimer: I don't have any details on the specific grant, so I may be completely mistaken...