DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 12 Aug 2007 17:14:17 -0700,    posted on: microsoft.public.dotnet.framework.windowsforms.databinding        back       

Thread Index
  1    NeilL
          2    Bob Powell [MVP]
          3    Marc Gravell
          4    Marc Gravell
                 5    NeilL
                        6    Marc Gravell
                        7    Marc Gravell
                 8    NeilL


Binding to a business object - Type name does not exist   
I know that this is really trivial but has been bugging me for some time and 
I can't figure out what I'm doing wrong.

I have a Windows form and I'm binding a business object (a class defined 
within the current application and current application namespace). When I 
define the datasource it creates the following

this.tasterBindingSource.DataSource = typeof(TastingMaster.Taster);

Which does not compile since the compiler can not resolve the class form how 
it was specified (namespacename.classname).  I get the error 

The type name 'Taster' does not exist in the type 
'TastingMaster.TastingMaster'	
 If I hand edit the above to either

this.tasterBindingSource.DataSource = typeof(global::TastingMaster.Taster);
or just
this.tasterBindingSource.DataSource = typeof(Taster);

Things work as expected.

So, can someone tell me how I should be doing this to get the code generated 
correctly the first time? 

By the way, I used the datasource wizard to create the above.

-- 
Neil
Date:Sun, 12 Aug 2007 17:14:17 -0700   Author:  

Re: Binding to a business object - Type name does not exist   
Why are you using the type of the object as the data source? surely you need 
a concrete instance of some class rather than it's type - which is a whole 
different thing -

Data source properties are usually Object based so that you can use any one 
of the various list, collection or bindinglist style objects so the property 
will happily accept a type but no sensible binding will take place.

-- 
-- 
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"NeilL"  wrote in message 
news:EBCD8704-DA6A-451D-A149-05AF47A9B492@microsoft.com...

>I know that this is really trivial but has been bugging me for some time 
>and
> I can't figure out what I'm doing wrong.
>
> I have a Windows form and I'm binding a business object (a class defined
> within the current application and current application namespace). When I
> define the datasource it creates the following
>
> this.tasterBindingSource.DataSource = typeof(TastingMaster.Taster);
>
> Which does not compile since the compiler can not resolve the class form 
> how
> it was specified (namespacename.classname).  I get the error
>
> The type name 'Taster' does not exist in the type
> 'TastingMaster.TastingMaster'
> If I hand edit the above to either
>
> this.tasterBindingSource.DataSource = 
> typeof(global::TastingMaster.Taster);
> or just
> this.tasterBindingSource.DataSource = typeof(Taster);
>
> Things work as expected.
>
> So, can someone tell me how I should be doing this to get the code 
> generated
> correctly the first time?
>
> By the way, I used the datasource wizard to create the above.
>
> -- 
> Neil 
Date:Mon, 13 Aug 2007 09:48:25 +0200   Author:  

Re: Binding to a business object - Type name does not exist   
To be fair to the OP, that is exactly what the IDE spits out... the 
binding code has a special case for Type instances, meaning that it 
(broadly) uses the TypeDescriptor.GetProperties(type) overload, rather 
than the TypeDescriptor.GetProperties(object) version. This means that 
it does, as you would hope, list the properties for the associated 
Type, rather than the properties of a Type instance.

Marc
Date:Mon, 13 Aug 2007 10:59:48 +0100   Author:  

Re: Binding to a business object - Type name does not exist   
Is this just because you have a form (or other class) or property 
whose name is the same (in a different namespace), thus confusing the 
compiler?

In which case either the global:: or an alias (using SomeOtherName = 
blah.bloop.ClassName) directive should suffice.

Marc
Date:Mon, 13 Aug 2007 11:01:52 +0100   Author:  

Re: Binding to a business object - Type name does not exist   
Marc,
Thanks for the reply. I don't have any other classes or forms with the same 
name in any namespace. This happens to be a class that is in a source file 
with another class and not is a separate .cs file but that should not be the 
problem.

Is there someplace in the IDE where I can specify the global:: so that I 
don't have to hand edit the designer generated code each time it gets 
regenerated?

Thanks
-- 
Neil


"Marc Gravell" wrote:


> Is this just because you have a form (or other class) or property 
> whose name is the same (in a different namespace), thus confusing the 
> compiler?
> 
> In which case either the global:: or an alias (using SomeOtherName = 
> blah.bloop.ClassName) directive should suffice.
> 
> Marc 
> 
> 
> 
Date:Mon, 13 Aug 2007 06:56:06 -0700   Author:  

Re: Binding to a business object - Type name does not exist   
Just as an aside - do you have a fragment (just a few classes etc) 
that reproduce this?

Marc
Date:Mon, 13 Aug 2007 15:13:29 +0100   Author:  

Re: Binding to a business object - Type name does not exist   
Not that I know of.

However - on a related note, allow me to warn you that the IDE 
sometimes gets very flakey about class bindings. If it decides it 
doesn't like you, it will throw them all away. As such, I tend to only 
work in the designer until it is "close enough", then I cut/paste the 
code into a private method (and call it at some point in the 
Form/Control startup).

Any more tweaks I do directly in the snipped code. You don't get to 
see the columns in the designer, but it tends to last longer.

Your mileage may vary ;-p

Marc
Date:Mon, 13 Aug 2007 15:12:50 +0100   Author:  

Re: Binding to a business object - Type name does not exist   
Thanks for the advice on not using the IDE after it gets close.  I've been 
using the Infragistics grid controls and have found that it does decide to 
discard all my stuff for no known reason so I was moving to your cut/paste 
approach.

I also tried editing the datasource file that had configuration info to see 
if I could fix it up there ... no luck with that either.

As for a sample, I don't have anything that I can do easily but let me see 
what I can do.

I've had exactly the same problem with components that I have in another 
project where, if I drop them on a form the code generated has the same type 
issue that I never figured out.

-- 
Neil


"Marc Gravell" wrote:


> Just as an aside - do you have a fragment (just a few classes etc) 
> that reproduce this?
> 
> Marc 
> 
> 
> 
Date:Mon, 13 Aug 2007 07:42:03 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us