Question
What is the difference between setting a [...].DataSource
to an instance of an object vs. the type of a class? I have seen both methods in use in our codebase, and I'm trying to wrap my head around why it is one way or the other in any of these cases.
Example
How does
object1.DataSource = typeof(SomeClass);
differ from
object2.DataSource = getSomeObject();
Further inquery
Also, in the first case, if I set a DataSource
to be the type of a class, what happens if that class is a base class? Does the data binding work on properties that only exist in classes that descend from the base class? Or does the data binding only work on the class members of the type of the class I set the DataSource
to?
I'm having a hard time wording my Google
search queries to give me an answer to this question. And that is either because this stuff is complicated and I'm just not wording it right, or I do not quite understand some of the fundamentals of data binding in C#. Could I get some help getting pointed in the right direction here? Thanks!
DataSource
property and the fact that you can assign a type to theDataSource
property. This makes it obvious that the question is about theSystem.Windows.Forms.BindingList.DataSource
property. There is not such property with that name where you can assign a type in WPF nor in ASP.NET. It troubles me a bit that I made an edit that the author of the question seems to approve and you still want to challenge this edit? – Martin Liversage Aug 18 '14 at 18:01DataSource
property. You are the only person who has ever mentionedBindingList
. I'm concerned because if you're in the habit of adding tags to questions in which that tag may well not apply then the fact that you happened to guess right this once doesn't mean you'll guess right every single other time you make such edits, and adding the wrong paradigm's tag can have significant negative consequences. – Servy Aug 18 '14 at 18:05