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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:29:27+00:00 2026-05-21T10:29:27+00:00

HI, I just came across good link and used that in my code.. how

  • 0

HI,

I just came across good link and used that in my code..

how to bind list to datagridview

I used

List<String> list_string= new List<String>();
DataGridView.DataSource = list_string.Select(x => new { Value = x }).ToList();

And now i have my values in the datagrid.

to bind my list to datagrid,but how to reverse the process?

i.e.

i want to do something like this

List<string> myList = datagridview1.datasource as list<string>;

But i am getting myList==null doesn’t contain any element.

regards,

Sangram Nandkhile.

  • 1 1 Answer
  • 2 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-21T10:29:28+00:00Added an answer on May 21, 2026 at 10:29 am

    By doing x => new { Value = x } you are projecting a new anonymous type and is no longer a List<string>

    In the same question your reference try and use the accepted answer and project out to a known type, that way you can retrieve the List<StringValue>

    List<String> list_string= new List<String>();
    DataGridView.DataSource = list_string.Select(x => new StringValue(x)).ToList();
    

    With that you can:

    List<StringValue> myList = datagridview1.datasource as List<StringValue>;
    

    And than to finally get your List<string>

    List<string> stringList = null;
    if(myList != null)
    {
      stringList = myList.Select(s=>s.Value).ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across code that looks like this: if (foo == bar){}else{ }
I just came across the most unexpected behavior. I'm sure there is a good
Just came across an issue with my Wordpress template that I can't figure out.
I just came across a query that does an inner join on a non-distinct
Just came across this quote in a book on OOP that I'm reading, A
I just came across the Hole in the Middle pattern and think that I
I'm pretty new to Design Patterns.I just came across Factory Design Pattern. I understood
Just came across this by Chris Coyier - http://css-tricks.com/examples/CSSTabs/ Can anyone explain me, how
I just came across a weird error: private bool GetBoolValue() { //Do some logic
I just came across an idea in The Structure And Interpretation of Computer Programs

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.