I have an array, arrStudents, that contains my students’ age, GPA, and name like so:
arrStudents[0].Age = "8"
arrStudents[0].GPA = "3.5"
arrStudents[0].Name = "Bob"
I tried to bind arrStudents to a DataGridView like so:
dataGridView1.DataSource = arrStudents;
But the contents of the array do NOT show up in the control. Am I missing something?
As with Adolfo, I’ve verified that this works. There is nothing wrong in the code shown, so the problem must be in the code you aren’t showing.
My guess:
Ageetc are not public properties; either they areinternalor they are fields, i.e.public int Age;instead ofpublic int Age {get;set;}.Here’s your code working for both a well-typed array and an array of anonymous types: