Loop through rows in a grid

I have a grid with three columns (id, name, checkbox). Now I want to loop through all rows in the grid and where checkbox is checked I want to insert a record into a table with data from the grid.
What would be the best way to do it and does anyone know of samples?