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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:24:58+00:00 2026-06-05T16:24:58+00:00

I have a large set of data that is generated from a web service

  • 0

I have a large set of data that is generated from a web service in my program. I need to display this data in a DataGrid, but the returned collections of data all have different formats (One may be 3 columns and the next 7) so I cannot create a specific object to hold this data. I am having trouble getting this information to display. Right now I am trying to use this method. I put the data into a two-dimensional list of KeyValuePairs. The Key being the Column this data would belong to, the Value being the output for that row. This is what I am trying right now.

private void SetDataValuesExecute(List<List<KeyValuePair<string,object>>> Data)
    {
        ResultsCollection = Data;
        ValuesDataGrid.Columns.Clear();
        foreach (string colName in Data[0].Select(x => x.Key).ToList())
        {
            DataGridTextColumn tempCol = new DataGridTextColumn();
            tempCol.Header = colName;
            Binding bind = new Binding();
            bind.Source = ResultsCollection.Select(x => x.FirstOrDefault(y => y.Key == colName).Value.ToString()).ToList();
            tempCol.Binding = bind;
            ValuesDataGrid.Columns.Add(tempCol);         
        }
    }

The ResultsCollection is a non-volatile variable to be used as the source of my bindings. It is a copy of all of the two-dimensional List data I need to construct the DataGrid.

This looks at the first entry an extracts the Column Header values and creates new columns based on that. The binding statement looks at each Row, grabs data for the specified Column, and tries to set that as the Column’s Binding. This allows me to have both the column name and a list of all the data that goes in that column. Unfortunately binding the list of data to the column ends up not displaying any data.

So my question is: How do I need to format my data in order for the Column Binding to actually display data? Am I approaching this situation all wrong? Any help is appreciated as I am quite stumped.

  • 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-05T16:25:00+00:00Added an answer on June 5, 2026 at 4:25 pm

    Here’s a complete working sample

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
    
            var data = new MyViewModel();
    
            int columnIndex = 0;
    
            foreach (var name in data.ColumnNames)
            {
                grid.Columns.Add(
                    new DataGridTextColumn
                    {
                        Header = name,
                        Binding = new Binding(
                            string.Format("Values[{0}]", columnIndex++))
                    });
            }
    
            DataContext = data;
        }
    }
    
    public class MyViewModel
    {
        public MyViewModel()
        {
            Items = new List<RowDataItem>
                {
                    new RowDataItem(),
                    new RowDataItem(),
                    new RowDataItem(),
                };
    
            ColumnNames = new List<string>{ "Col 1", "Col 2", "Col 3"};
        }
    
        public IList<string> ColumnNames { get; private set; }
    
        public IList<RowDataItem> Items { get; private set; }
    }
    
    public class RowDataItem
    {
        public RowDataItem()
        {
            Values = new List<string>{ "One", "Two", "Three"};    
        }
    
        public IList<string> Values { get; private set; }
    }
    

    The Xaml

    <Grid>
        <DataGrid x:Name="grid" ItemsSource="{Binding Items}" 
                  AutoGenerateColumns="False"/>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a large set of data that looks like this [('ART', [100,
I have a large data set that I'm working with in excel. About 1000+
I have a very large possible data set that I am trying to visualize
I have a relatively large set of data that lends itself very naturally to
I have a large set of data that I've collected that I'd like to
I have a large data.frame that was generated by a process outside my control,
I have a large set of data which I access via a generator/iterator. While
Interpolating Large Datasets I have a large data set of about 0.5million records representing
I have implemented paging for a large set of data in an application by
I have situation where a user can manipulate a large set of data (presented

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.