You can use attributes on the page. easiest would be to create a detail using section wizard. It will create a detail schema and page schema for you. On the page schema you can use attributes (as in normal page) and dependencies. And this logic will trigger whenever you will be changing anything in the grid.
Also note that business rules and rules will work this way as well if you need those.