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 data from a table in a database (string) that contain text and
I have to delete some rows from a data table. I've heard that it
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17
I have a two-dimensional array (of Strings) which make up my data table (of
I have a small app/site on a dev server with a data table in
Greetings, I have data stored on mysql with delimiter , in 1 table. I
I have some data grouped in a table by a certain criteria, and for
I have a table of the form CREATE TABLE data { pk INT PRIMARY
I have a data tables with this type of setup. Table A AID AName
I have a table of data, and I allow people to add meta data

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.