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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:26:26+00:00 2026-05-14T03:26:26+00:00

In an assembly I created a class like the following: [DataObject(true)] public class A

  • 0

In an assembly I created a class like the following:

[DataObject(true)]
public class A
{
 public int Foo{get;set;}

 [DataObjectMethod[DataObjectMethodType.Select)]
 public static List<A> GetAllA(string ConnectionString)
 {
   // return filled List<A>
 }
}

Now I want to display this List with a Gridcontrol under Winforms. I though of a DataGrid.
Though I’m coming from ASP.net I’d first think of

this.dataGridView1.DataSource = A.GetAllA(ConnectionString)

Works, but I’d prefer a better databinding with BindingSources. (Because I’ve always heard that thats the way to go)
I managed to drop a BindingSource onto the form and set the DataSource property to class A.
But where can I set the SelectMethod and its parameters? If I set DataSource property of the dataGridView to the BindingSource, it will only display an empty line.

Is this the right way to go? Will it only require some additional clicks in the wizard, or do I need to read tons of documentation to get this working?

Edit: Is there even a way to achieve automatically binding to my select method? Or does the BindingSource only supports mapping the columns, but not actually binding the data, meaning I’m required to set the DataSource property nevertheless?

  • 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-14T03:26:27+00:00Added an answer on May 14, 2026 at 3:26 am

    You need to create a DataSource. Click “Data” menu and select “Add New DataSource…”

    Connecting to Data in Visual Studio Overview
    http://msdn.microsoft.com/en-us/library/wxt2cwcc(VS.80).aspx

    To connect your application to data in
    a database, Web service, or object,
    run the Data Source Configuration
    Wizard

    by selecting Add New Data Source from
    the Data Sources
    Window
    .

    Public Class A
        Private _field As String
        Public Property Field() As String
            Get
                Return _field
            End Get
            Set(ByVal value As String)
                _field = value
            End Set
        End Property
    End Class
    
    Public Class AListing
        Inherits List(Of A)
    End Class
    
    • Use AListing as the object when adding a data source. Good for grid views or detail forms that provide navigation. It is up to you to populate it.
    • Use A as the object when adding a data source. Good for a dialog when you only need to bind to one instance. It is up to you to populate it.

    A DataSource just helps the designer configure data binding. You still have to fill the objects. If you do not care about designer support, calling as you do is fine. Using a BindingSource just allows you to use an object like a “data table”. Using your example, if I use a BindingSource, I could handle the CurrentChanged event for any additional processing.

    this.dataGridView1.DataSource = A.GetAllA(ConnectionString);
    //-or-
    this.bindingSource1.DataSource = A.GetAllA(ConnectionString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 343k
  • Answers 343k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Typically, the best way to do something like this is… May 14, 2026 at 5:21 am
  • Editorial Team
    Editorial Team added an answer Your code could really use some error checking. Make sure… May 14, 2026 at 5:21 am
  • Editorial Team
    Editorial Team added an answer Use NCalc : stable, simple, and powerful May 14, 2026 at 5:21 am

Related Questions

I'm using SQL Server 2005 Analysis Services and I'm trying to calculate distance inside
I am building my first user control and I would like to package the
i have this code in one of my asp.net mvc views: <%Html.RenderFile(@C:\Members\newsletters\welcome.html);%> I have
I'm having a very hard time trying to access a custom configuration section in
Background I am trying to create a copy of a business object I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.