Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:01:08+00:00 2026-06-11T00:01:08+00:00

I have an array, arrStudents, that contains my students’ age, GPA, and name like

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:01:10+00:00Added an answer on June 11, 2026 at 12:01 am

    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: Age etc are not public properties; either they are internal or they are fields, i.e. public int Age; instead of public int Age {get;set;}.

    Here’s your code working for both a well-typed array and an array of anonymous types:

    using System;
    using System.Linq;
    using System.Windows.Forms;
    public class Student
    {
        public int Age { get; set; }
        public double GPA { get; set; }
        public string Name { get; set; }
    }
    
    internal class Program
    {
        [STAThread]
        public static void Main() {
            Application.EnableVisualStyles();
            using(var grid = new DataGridView { Dock = DockStyle.Fill})
            using(var form = new Form { Controls = {grid}}) {
                // typed
                var arrStudents = new[] {
                    new Student{ Age = 1, GPA = 2, Name = "abc"},
                    new Student{ Age = 3, GPA = 4, Name = "def"},
                    new Student{ Age = 5, GPA = 6, Name = "ghi"},
                };
                form.Text = "Typed Array";
                grid.DataSource = arrStudents;
                form.ShowDialog();
    
                // anon-type
                var anonTypeArr = arrStudents.Select(
                    x => new {x.Age, x.GPA, x.Name}).ToArray();
                grid.DataSource = anonTypeArr;
                form.Text = "Anonymous Type Array";
                form.ShowDialog();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array that looks like this, Array ( [email_address] => Array ( [0]
I'm using 2010 Express and I have an array arrStudents, where each element contains
I am using Visual C# 2010 Express. I have an array of students that
I have array of Objects (let say that class name is Snap) Snap. Is
I have array of objects person (int age; String name;) . How can I
I have array like this: array( 'person0' => array( 'name'=>'name0','address'=>'address0' ), 'person1' => array(
I have array output like this. { id = 1; user = { name=ABC
I have array like this: array('1224*', '543*', '321*' ...) which contains about 17,00 "masks"
I have array like below array(1) { [data]=> array(6) { [0]=> array(2) { [name]=>
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.