[SalesForce] Compile Error: Illegal assignment from List <...> to String

I am trying to find how to go about resolving this error.

Compile Error: Illegal assignment from List to String at line 23 column 13

By the way, the data type for "SurveySelection__c" is Number(2,0).

I am not sure whether that matters.

Bottom is my code:

public class WrapperDemoController{

public class TableRow{
    public String sfsid {get;set;}
    public String SurveySelection   {get;set;}
}

public List<TableRow> RowList {get; set;}

public WrapperDemoController(){

    RowList = new List<TableRow>();
    TableRow tr;

    for(Student__c con : [SELECT sfsid__c, (select SurveySelection__c from SurveySelections__r) FROM Student__c]){

        tr = new TableRow();
        tr.sfsid = con.sfsid__c;
        tr.SurveySelection = con.SurveySelections__r;  // Line 23: This is line where error occurs**

        RowList.add(tr);
    }
}
}  

Best Answer

If you just want the string value then you can do this:

tr.SurveySelection = con.SurveySelections__r.isEmpty() ? null : con.SurveySelections__r[0].SurveySelection__c;

If you have multiple rows you will need to figure out which one you want to get. Since the query on the related records is a List of the related records you cannot just assign the list to a string.