How to get data from DataGrid with radio buttons

I want to make a DataGrid, with one column containing names of famous persons, and other columns contain radio buttons, each of which characterizes his knowledge of the person.
The structure of the DataGrid is following:
Person name | Don’t know | Heard smth | Know very well

I have created such a DataGrid, but I don’t know how to get info when users select some answer and click submit button.
One of the problems is that DataGrid and RowTemplate (where I set repeating panel structure) are two different independent forms.

How can I extract info from the DataGrid? Thanks in advance!

Radio Buttons are a little odd, in that you have multiple visual components, all effectively sharing a single value. That breaks the usual Data Binding thinking.

Getting organized is at least half the battle. The DataGrid+RowTemplate design is a divide-and-conquer solution. Each Grid instance manages its own list of records. Each RowTemplate instance manages the contents of one record. Neither component has to do or know the whole job, in itself, and so it’s simpler than some big, knows-it-all solution.

In broad terms, you can follow the same simplifying pattern. For example,

  1. Add a function to your RowTemplate to read its Radio Buttons. Because each instance is dealing with a limited scope – only its own data record – there are a lot of higher-level details that just don’t matter at this level. All it has to worry about is identifying the current choice (see RadioButton’s get_group_value()), in just that particular record, and returning the that value to some caller.

  2. That caller, of course, will be your function, in the Form, that responds to the Submit button. It can iterate over all the Grid’s Template instances (get_components()), to collect those values.