Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Sat, 07 Jan 2006 12:04:02 -0600,    group: microsoft.public.dotnet.datatools        back       


Using Objects as Data Sources   
VS 2005 has the option of using objects as datasources.

I'm able to add a an object to my project as a datasource by using the
Data Source Configuration Wizard, but can't seem to make it do
anything.  For example when I bind a list<> object to a DataGridView
control a BindingSource and BindingNavigator are created as I
expected, but when data is entered into the columns of the grid, they
disappear as soon as I move out of the cell.

I suspect this is because I have not prepared the object properly for
databinding, but I can't find anything that describes how objects that
are to be databound are to be constructed.

Can anyone tell me where I can find some information on designing
objects that will be used for databinding?

Thanks,

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
date: Sat, 07 Jan 2006 12:04:02 -0600   author:   Otis Mukinfus

Re: Using Objects as Data Sources   
To be a data source the type of the object must implement the IEnumerable 
interface, which the List<> type does. I'm new to .NET 2.0 but I think the 
syntax when doing this in code would be like:

class Person
{
    public string firstName;
    pubic string lastName;
}

List<Person> people= new List<Person>();
person1 = new Person();
person1.firstName = "Steve";
person1.lastName = "Smith";
person2 = new Person();
person2.firstName = "Sue";
person2.lastName = "Sorensen";
people.Add(person1);
people.Add(person2);

myDatagrid.DataSource = people;
myDatagrid.AutoGenerateColumns = true;
myDatagrig.DataBind();

I've done this many times using .Net1.1 and it works. I can't tell if there 
is something wrong with the wizard since I haven't used it.

Hope this helps,
mortb





"Otis Mukinfus"  wrote in message 
news:hevvr1djvm44r7n8st7c8adb5vf7den97u@4ax.com...
> VS 2005 has the option of using objects as datasources.
>
> I'm able to add a an object to my project as a datasource by using the
> Data Source Configuration Wizard, but can't seem to make it do
> anything.  For example when I bind a list<> object to a DataGridView
> control a BindingSource and BindingNavigator are created as I
> expected, but when data is entered into the columns of the grid, they
> disappear as soon as I move out of the cell.
>
> I suspect this is because I have not prepared the object properly for
> databinding, but I can't find anything that describes how objects that
> are to be databound are to be constructed.
>
> Can anyone tell me where I can find some information on designing
> objects that will be used for databinding?
>
> Thanks,
>
> Otis Mukinfus
> http://www.otismukinfus.com
> http://www.tomchilders.com
date: Wed, 25 Jan 2006 10:36:53 +0100   author:   mortb

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us