So long as the values match and you can relate the data that is all that matters. This looks like it would to that, you would just need to remember that the order reference id maps to the detail order id.
If you can post back with a copy of the page with this code I could check it to see if it looks ok.