When you generate your checkboxes be sure to craft a name for them that is representative of the ID of the category/subcategory that is being rendered. When your form is returned to the server (POSTed) you will be able to read the value of the name.
If you are using ASP.NET and MVC
I have a post[
^] on advanced model binding where I address this issue head-on.
Cheers.