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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:04:12+00:00 2026-05-15T23:04:12+00:00

I have a datagrid populated by a Linq query. When the focused row in

  • 0

I have a datagrid populated by a Linq query. When the focused row in the datagrid changes I need to set a variable equal to one of the properties in that object.

I tried…

var selectedObject = view.GetRow(rowHandle);
_selectedId = selectedObject.Id;

… but the compiler doesn’t care for this at all (“Embedded statement cannot be a declaration or labled statement”).

It seems like the property should be easy to access. Inspecting the object during runtime shows all the properties I expect, I just don’t know how to access them.

How can I get access to the anonymous object’s property?

Edit for Clarifications:

I happen to be using DevExpress XtraGrid control. I loaded this control with a Linq query which was composed of several different objects, therefore making the data not really conforming with any one class I already have (ie, I cannot cast this to anything).

I’m using .NET 3.5.

When I view the results of the view.GetRow(rowHandle) method I get an anonymous type that looks like this:

{ ClientId = 7, ClientName = "ACME Inc.", Jobs = 5 }

My objective is to get the ClientId from this anonymous type so I can do other things (such as a load a form with that client record in it).

I tried a couple of the suggestions in the early answers but was unable to get to a point where I could get this ClientId.

  • 1 1 Answer
  • 1 View
  • 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-15T23:04:13+00:00Added an answer on May 15, 2026 at 11:04 pm

    Have you ever tried to use reflection? Here’s a sample code snippet:

    // use reflection to retrieve the values of the following anonymous type
    var obj = new { ClientId = 7, ClientName = "ACME Inc.", Jobs = 5 }; 
    System.Type type = obj.GetType(); 
    int clientid = (int)type.GetProperty("ClientId").GetValue(obj, null);
    string clientname = (string)type.GetProperty("ClientName").GetValue(obj, null);
    
    // use the retrieved values for whatever you want...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid, populated with objects in an ArrayCollection. After updating one of
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
I have a DataGrid that is populated by an xml response of a web
I have a datagrid which is populated with CSV data when the user drag/drops
I have a datagrid, populated as shown below. When the user clicks on a
I have a DataGrid, with an ItemTemplate that has an image and label. In
ASP.NET 1.1 - I have a DataGrid on an ASPX page that is databound
I have a DataGrid which is being bound dynamically to a database query. The
I have a datagrid in a WPF populated from a csv file. This is
I have a datagrid which populated by some data from sqlserver.I have datetime filed

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.