Can I set multiple List Item property values with Reflection?

61 Views Asked by At

In continuation to: Can I set a property value with Reflection?, I have a challenge-

class Student
{
    public string Name { get; set; }
    public List<ListItem> Courses { get; set; }
}

List Selections has 2 Items 1.

{
Text = 'Business Management', Value = 'Course 1', Selected = 'true'
}
{
Text = 'Network Management', Value = 'Course 2', Selected = 'false'
}

How do I assign the Selections to Courses property of the Student class?

1

There are 1 best solutions below

0
vishwa On

To answer to this, I have found that .net automatically identifies the Property as List and I have been able to loop through and assign values using the property.SetValue() method