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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:30:16+00:00 2026-05-18T06:30:16+00:00

I have a DataGridView with myGridView.DataSource = GetSomeData() // method called public IQueryable GetSomeData()

  • 0

I have a DataGridView with

myGridView.DataSource = GetSomeData()


// method called
public IQueryable GetSomeData()
{
    var source = from r in records
                 select r;

    return source;    // made correction from 'r' to 'source'
}

GetSomeData() fills the DataGridView as expected. The user will select a row to edit which then passes the row data to a form. Since the DataGridViewRow.DataBoundItem is an anonymous type, how can I pass DataBoundItem?

I half expected that my DataBoundItem would be IQueryable – incorrect. Here is the info from the debugger on the DataBoundItem property:

DataBoundItem { CustomerID = “3133”,
Last_Name = “Smith”, First_Name =
“John”, AccountNumber = “JS3133”,
ActiveYN = True } < Anonymous Type >

Once the data is passed to the new form, I would like to do something like:

txtFName.Text = SomeEnumeratedObject["First_Name"];
txtLName.Text = SomeEnumeratedObject["Last_Name"];

Any ideas on how I can do this? It would be even better, IMO, if the controls on the new form could some how be bound to SomeEnumeratedObject.

Would it possible to query the DataBoundItem with LINQ?

Edit:

Changed method:

public DataView GetSomeData()
{
    var source = from r in records
                 select r;

    DataTable table = ToDataTable(myContext, source);
    return new DataView(table);
}

See complete solution here.

  • 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-18T06:30:16+00:00Added an answer on May 18, 2026 at 6:30 am

    You could pass it as dynamic and access the properties that way:

    public void Test(dynamic item)
    {
        MessageBox.Show(string.Format("{0} : {1}", item.First_Name, item.Last_Name));
        textBox1.DataBindings.Add("Text", _item, "First_Name");
        textBox2.DataBindings.Add("Text", _item, "Last_Name");
    }
    

    One thing to consider is that properties on anonymous types are read only, so your user will not be able to edit the values that way. From the C# Language Spec:

    The members of an anonymous type are a sequence of read-only properties inferred from the anonymous object initializer used to create an instance of the type.

    You should consider declaring a type for this instead of using an anonymous type. That way you’ll also get the benefit of intellisense and be able to rename/refactor your properties without any problems.

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

Sidebar

Related Questions

I have datagridview and textboxes on form. I load records from different tables when
i have a DataGridView on the Form. I select some data from database and
I have DataGridView and I set DataSource of datagridview by using DataTables. DataTable dt
I have a datagridview, and it loads information from db. However, at run time,
I have a datagridview bound to a datasource, column[0] AgencyName is a primary key
I have DataGridView and DataTable with my players. DataTable dt = Extensions.ToDataTable<Player>(PlayerList); Grid.DataSource =
I have datagridview on my winform. I am displaying records in the datagridview. Now
I have datagridview with paging enabled. But when I want to move from page
Hi I have DataGridView control that I manyally fill with items (no DataSource) like
I have a DataGridView (called DataGridViewSecurity) in VB.net (Visual Studio 2010) which is bound

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.