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 8693853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:38:21+00:00 2026-06-13T00:38:21+00:00

I want to display a grid where it shows invitee information and – and

  • 0

I want to display a grid where it shows invitee information and – and that’s the tricky part – columns indicating which mails they have received.

For instance, a grid like this:

Firstname | Lastname | ReceivedMail1 | ReceivedMail2

If a third mail is created in the application, I the grid needs to add a column like this:

Firstname | Lastname | ReceivedMail1 | ReceivedMail2 | ReceivedMail3

My database is relational, so there’s someting like person.receivedEmails with a collection of e-mails.

I’m looking for a best practice to go about this. I’m working in C# in a WinForms app, but I need this for my webapp too. I am considering a dynamic object (although I’m not sure how good that works with the grid), or maybe a database view. Any suggestions?

  • 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-13T00:38:23+00:00Added an answer on June 13, 2026 at 12:38 am

    OK, this is how I’m going to do it.
    Thanks to Adding-properties-To-ExpandoObjects and Binding-ExpandoObjects-ToDatagrid

    Here’s a prototype:

            dynamic obj = new ExpandoObject();
            obj.FirsName = "John";
            obj.LastName = "Doe";
            var x = obj as IDictionary<string, Object>;
            for (int i = 0; i < 3; i++)
            {
                x["ReceivedMail_" + i] = true;
            }
    
            var data = new List<ExpandoObject>() { obj };
            this.dataGridView1.DataSource = data.ToDataTable();
    

    using that method from the 2nd link:

        public static class DynamicIENumerableExtension
    {
        public static DataTable ToDataTable(this IEnumerable<dynamic> items)
        {
            var data = items.ToArray();
            if (data.Count() == 0) return null;
    
            var dt = new DataTable();
            foreach (var key in ((IDictionary<string, object>)data[0]).Keys)
            {
                dt.Columns.Add(key);
            }
            foreach (var d in data)
            {
                dt.Rows.Add(((IDictionary<string, object>)d).Values.ToArray());
            }
            return dt;
        }
    

    Result is EXACTLY like I wanted. 🙂

    Result

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display and edit some objects in a WPF data grid and
I have a list of images in grid view.I want to display a gallery
I've following Grid to display data, now when I want to add new record
I've got a grid that only displays one piece of information such as a
I want to use a GridView to display data that is separated alphabetically by
I want to display the grid view like this -(fig 1) Sr.no Class ----Division------
I want display data from database in Listbox...Here is my code, It is not
i want display 1 record from colums zodys , I'm programint in C# I
I have a simple quiz application and I want display a nice timer /
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in

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.