Could We create a structure so that it could be binded as a datasource to control who supports databinding.
If yes Could any body provide me a sample (with code) of creating our own datasource in C#.That is i don't wan't to bind to dataset ,xml etc I wan't to create my own datastructure.What I have to do.

Creating our own datasource
RossDonald
I don't undestand you question, in sample I provide you make your own class that will act as datasource object in the databinding.
If you ask about generic classes, then I can say they don't work with such technique. But you can always make non-generic subclass from generic and use it in datasource.
If you ask about data source that is own database or some other data provider, then it's about creating own Data Providers, no binding issues here.
Give a little more information about what you want to do, please.
Marsan001
I suggest you read this 3 MSDN topics (inside "Windows Forms Data Binding")
Sample in MSDN: "How to: Bind a Windows Forms Control to a Factory Object" (it looks just like one you provide)
tonante
Hi!
Create any class (structure is bad solution) and declare there public properties (they will be bindable). Like this:
public
class Person{
public string Name { get { return _Name; } set { _Name = value; } } public string Phone { get { return _Phone; } set { _Phone = value; } } string _Name; string _Phone;}
To make it a datasource, go to "Data\Add new data source" menu and select "Object" in first page, then select your class.
easan
Segrey Could you give me a sample or point to the sample link
Also I got a reply from some other forum as
That is not to hard.I will use a repeater as a sample.
Repeater.Datasource = SomeFunction(SomeParameter);
Repeater.DataBind();
This is the function. Here i use a Generic List which is ideal for this purpose;
function List<YourStructureOrClass> SomeFunction(int SomeParameter) {
List<YourStructureOrClass> L = new List<YourStructureOrClass>();
YourStructureOrClass YSOC = new YourStructureOrClass();
YSOC.SomeProperty = SomeValue;
L.Add(YSOC);
return L;
}
What about this idea
Nate Dogg
st23am23
Yes you can use this class for simple data binding (for example to TextBox.Text property you can bind Name).
Binding works with any class that have public properties.
If you want bindable list (list items in combobox for example), then your class must be a collection with System.ComponentModel.IBindingList or System.ComponentModel.IBindingListView interface implementation.
JOESOL643
By generic I mean General not the generic you understand.
Could I bind Your class as datasource to the combo,textbox,gridview,e.t.c
I wan't to create such a datastructure .Hope any body can understand