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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:03:32+00:00 2026-05-16T22:03:32+00:00

I have a data table. If I set the DataSource of a DataGrid to

  • 0

I have a data table. If I set the DataSource of a DataGrid to the data table it displays all of the data just fine. However if I use a lambda expression to filter out some of the data and then reassign the datasource it does not display anything. This is what I have tried…

var AllPeople = 
    from r in CompanyDataTable.AsEnumerable()
    select new
    {
        FirstName = r.Field<string>("FirstName"),
        LastName = r.Field<string>("LastName"),
        Gender = r.Field<string>("Gender"),
        Age = r.Field<double>("Age"),
        City = r.Field<string>("City"),
        State = r.Field<string>("State"),
        Cagegory = r.Field<string>("CategoryGroup"),
    };

SomeDataGrid.DataSource = AllPeople;

This compiles just fine and runs fine too but the data grid is empty. If I pause execution after executing the lambda expression I can see taht AllPeople does contain a list of data it just donsn’t get displayed. Does using AsEnumerable prevent you from using the data in a datagrid or something? How can I fix this?

  • 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-05-16T22:03:33+00:00Added an answer on May 16, 2026 at 10:03 pm

    While setting the datasource you missed to convert into a list

    var AllPeople = 
        (from r in CompanyDataTable.AsEnumerable()
        select new
        {
            FirstName = r.Field<string>("FirstName"),
            LastName = r.Field<string>("LastName"),
            Gender = r.Field<string>("Gender"),
            Age = r.Field<double>("Age"),
            City = r.Field<string>("City"),
            State = r.Field<string>("State"),
            Cagegory = r.Field<string>("CategoryGroup"),
        }).ToList();
    

    Or

    SomeDataGrid.DataSource = AllPeople.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql table field set as time type which stores data in
I have set up 2 two tables - table userid and table data in
I have two tables set up in phpmyadmin- table userid and table data. The
I have produced a data table. All the columns are sortable. It has a
I have a DataGrid that is loaded from an XML data store, all created
I have a data table. After creating this table, I use data grid view
I have a table with say 1640 items. I set bindingSource.Filter = some filter
I have a datagridview its datasource is set to a data view -> data
I have DataGridView and I set DataSource of datagridview by using DataTables. DataTable dt
I have a ComboBox with its DataSource set to an instance of a DataTable.

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.