Subform code help

Subform code help

In my application, I have a list of students for each class. I input all student names from the class to a roll to be marked via the script below. Each student in the list has their own record and I am trying to find a way to input each students photo when the names are input into the roll subform. I have highlighted the code I tried but it doesn’t work. Any advice how I could do this? Thanks!

input.Student_List.clear();
fetchStudents = Add_a_Class[ID == input.Class_Name].Students;
rows = Collection();
for each  stud in fetchStudents
{
row = Mark_Class_Roll.Student_List();
row.Photo=stud.Photo;
row.Student=stud;
row.Status="Present";
row.Notification="-";
row.Reason="-";
row.Date_field1=input.Date_field;
row.Classes=input.Class_Name;
rows.insert(row);
}
input.Student_List.insert(rows);