473,549 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BusinessObject update on DetailsView - Exception "No parameterlessco nstructor defined for this object"

I have the following business Object(s):

public class ParentObject
{
public ParentObject(st ring somestring)
{
...-
}

....

}

public class MyBusinessObjec t : global::ParentO bject
{
public MyBusinessObjec t (string somestring)
: base(somestring )
{
...
}
// some properties and other stuff
}
On a page I have defined a ObjectDataSourc e for MyBusinessObjec t. It
has a select and update method. It has handlers for OnSelected,
OnSelecting, OnCreating, OnUpdating. It has select parameters.

Select works fine, I could work around the 'Parameterless constructor
exception' by doing:

protected void MyBusinessObjec tDS_Creating(ob ject sender,
ObjectDataSourc eEventArgs e)
{
BO_MyBusinessOb ject mbo = new BO_MyBusinessOb ject(somestring );
e.ObjectInstanc e = mbo;
}

This works just fine!

PROBLEM is the update method!

In my <asp:DetailsVie wcontrol I have defined a OnItemUpdating
EventHandler. This gets calls. After that I get the following
exception:

[MissingMethodEx ception: No parameterless constructor defined for this
object.]
System.RuntimeT ypeHandle.Creat eInstance(Runti meType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHa ndle& ctor, Boolean& bNeedSecurityCh eck) +0
System.RuntimeT ype.CreateInsta nceSlow(Boolean publicOnly, Boolean
fillCache) +103
System.RuntimeT ype.CreateInsta nceImpl(Boolean publicOnly, Boolean
skipVisibilityC hecks, Boolean fillCache) +268
System.Activato r.CreateInstanc e(Type type, Boolean nonPublic) +66
System.Web.UI.W ebControls.Obje ctDataSourceVie w.BuildDataObje ct(Type
dataObjectType, IDictionary inputParameters ) +39

System.Web.UI.W ebControls.Obje ctDataSourceVie w.ExecuteUpdate (IDictionary
keys, IDictionary values, IDictionary oldValues) +1294
System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
values, IDictionary oldValues, DataSourceViewO perationCallbac k
callback) +78
System.Web.UI.W ebControls.Deta ilsView.HandleU pdate(String
commandArg, Boolean causesValidatio n) +1152
System.Web.UI.W ebControls.Deta ilsView.HandleE vent(EventArgs e,
Boolean causesValidatio n, String validationGroup ) +440

I also have a Updating handler on my ObjectDataSourc e. BUT THIS
HANDLER GETS NEVER CALLED, IT CRASHES BEFORE!

Any idea, how I can update with a business object, that has
parameterized constructors??? (I need them, otherwise the objects
could be instantiated without being correctly initialized).

Many thanks for your suggestions

Tom

Oct 29 '08 #1
2 3264
the ObjectDataSourc e Update,Iinsert, and Delete methods create an instance of
the TypeName to perform these actions. the TypeName object can not have any
contructor parametes as there is no way to define them.

you should make a new object (adapter) that hosts the methods, and creates
correct underlying business objects. its you can use the paramter collection
and the Updating... events to create the underlying objects. a bad practice
to put database methods in a buisiness object anyway, as you want seperation
of layers.

-- bruce (sqlwork.com)
"be************ @gmail.com" wrote:
I have the following business Object(s):

public class ParentObject
{
public ParentObject(st ring somestring)
{
...-
}

....

}

public class MyBusinessObjec t : global::ParentO bject
{
public MyBusinessObjec t (string somestring)
: base(somestring )
{
...
}
// some properties and other stuff
}
On a page I have defined a ObjectDataSourc e for MyBusinessObjec t. It
has a select and update method. It has handlers for OnSelected,
OnSelecting, OnCreating, OnUpdating. It has select parameters.

Select works fine, I could work around the 'Parameterless constructor
exception' by doing:

protected void MyBusinessObjec tDS_Creating(ob ject sender,
ObjectDataSourc eEventArgs e)
{
BO_MyBusinessOb ject mbo = new BO_MyBusinessOb ject(somestring );
e.ObjectInstanc e = mbo;
}

This works just fine!

PROBLEM is the update method!

In my <asp:DetailsVie wcontrol I have defined a OnItemUpdating
EventHandler. This gets calls. After that I get the following
exception:

[MissingMethodEx ception: No parameterless constructor defined for this
object.]
System.RuntimeT ypeHandle.Creat eInstance(Runti meType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHa ndle& ctor, Boolean& bNeedSecurityCh eck) +0
System.RuntimeT ype.CreateInsta nceSlow(Boolean publicOnly, Boolean
fillCache) +103
System.RuntimeT ype.CreateInsta nceImpl(Boolean publicOnly, Boolean
skipVisibilityC hecks, Boolean fillCache) +268
System.Activato r.CreateInstanc e(Type type, Boolean nonPublic) +66
System.Web.UI.W ebControls.Obje ctDataSourceVie w.BuildDataObje ct(Type
dataObjectType, IDictionary inputParameters ) +39

System.Web.UI.W ebControls.Obje ctDataSourceVie w.ExecuteUpdate (IDictionary
keys, IDictionary values, IDictionary oldValues) +1294
System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
values, IDictionary oldValues, DataSourceViewO perationCallbac k
callback) +78
System.Web.UI.W ebControls.Deta ilsView.HandleU pdate(String
commandArg, Boolean causesValidatio n) +1152
System.Web.UI.W ebControls.Deta ilsView.HandleE vent(EventArgs e,
Boolean causesValidatio n, String validationGroup ) +440

I also have a Updating handler on my ObjectDataSourc e. BUT THIS
HANDLER GETS NEVER CALLED, IT CRASHES BEFORE!

Any idea, how I can update with a business object, that has
parameterized constructors??? (I need them, otherwise the objects
could be instantiated without being correctly initialized).

Many thanks for your suggestions

Tom

Oct 29 '08 #2
On 29 Okt., 18:11, bruce barker
<brucebar...@di scussions.micro soft.comwrote:
the ObjectDataSourc e Update,Iinsert, and Delete methods create an instance of
the TypeName to perform these actions. the TypeName object can not have any
contructor parametes as there is no way to define them.

you should make a new object (adapter) that hosts the methods, and creates
correct underlying business objects. its *you can use the paramter collection
and the Updating... events to create the underlying objects. a bad practice
to put database methods in a buisiness object anyway, as you want seperation
of layers.

-- bruce (sqlwork.com)

"bednarz.tho... @gmail.com" wrote:
I have the following business Object(s):
public class ParentObject
{
* *public ParentObject(st ring somestring)
* *{
* * ...-
* *}
* ....
}
public class MyBusinessObjec t : global::ParentO bject
{
* * public MyBusinessObjec t (string somestring)
* * * * : base(somestring )
* * {
* * * * * ...
* * }
* * // some properties and other stuff
}
On a page I have defined a ObjectDataSourc e for MyBusinessObjec t. It
has a select and update method. It has handlers for OnSelected,
OnSelecting, OnCreating, OnUpdating. It has select parameters.
Select works fine, I could work around the 'Parameterless constructor
exception' by doing:
protected void MyBusinessObjec tDS_Creating(ob ject sender,
ObjectDataSourc eEventArgs e)
{
* * * * BO_MyBusinessOb ject mbo = new BO_MyBusinessOb ject(somestring );
* * * * e.ObjectInstanc e = mbo;
}
This works just fine!
PROBLEM is the update method!
In my <asp:DetailsVie wcontrol I have defined a OnItemUpdating
EventHandler. This gets calls. After that I get the following
exception:
[MissingMethodEx ception: No parameterless constructor defined for this
object.]
* *System.Runtime TypeHandle.Crea teInstance(Runt imeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHa ndle& ctor, Boolean& bNeedSecurityCh eck) +0
* *System.Runtime Type.CreateInst anceSlow(Boolea n publicOnly, Boolean
fillCache) +103
* *System.Runtime Type.CreateInst anceImpl(Boolea n publicOnly, Boolean
skipVisibilityC hecks, Boolean fillCache) +268
* *System.Activat or.CreateInstan ce(Type type, Boolean nonPublic) +66
* *System.Web.UI. WebControls.Obj ectDataSourceVi ew.BuildDataObj ect(Type
dataObjectType, IDictionary inputParameters ) +39
System.Web.UI.W ebControls.Obje ctDataSourceVie w.ExecuteUpdate (IDictionary
keys, IDictionary values, IDictionary oldValues) +1294
* *System.Web.UI. DataSourceView. Update(IDiction ary keys, IDictionary
values, IDictionary oldValues, DataSourceViewO perationCallbac k
callback) +78
* *System.Web.UI. WebControls.Det ailsView.Handle Update(String
commandArg, Boolean causesValidatio n) +1152
* *System.Web.UI. WebControls.Det ailsView.Handle Event(EventArgs e,
Boolean causesValidatio n, String validationGroup ) +440
I also have a Updating handler on my ObjectDataSourc e. BUT THIS
HANDLER GETS NEVER CALLED, IT CRASHES BEFORE!
Any idea, how I can update with a business object, that has
parameterized constructors??? (I need them, otherwise the objects
could be instantiated without being correctly initialized).
Many thanks for your suggestions
Tom
Hi Bruce,

Thanks for that feedback. Do you know of any link that shows some
'best practice' when working with Business Objects and ASP.NET? I have
some experience with Java and Application Servers like JBoss, Tomcat,
Geronimo etc. Seems all to be a bit different with MS technology.

Tom
Oct 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3303
by: Dr Duck | last post by:
GDay all, Something seems odd to me.... I wrote a simple C# function public void bind(ref object a, ref object b, bool atob) { if(atob) b = a; else
134
7785
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you...
11
9816
by: MLH | last post by:
I copied the following code snippet from A97 HELP. Am getting an error at compile time suggesting there's a problem with the first line (compile error, user-defined type not defined). It is likely that I've left something out. Doesn't seem to like Dim dbs as Database - that's what's hi-lited after acknowledging the error. Can you see anything...
5
8068
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right thing to do. And I wonder why VB .NET keeps silence and makes such function return some default value instead. Isn't it error-prone? -- Dmitriy...
1
2282
by: dasayu | last post by:
Hi, I have a custom object called gridWidget. I am consistantly getting an error in FireFox when I click on an href, which calls a function defined on the object. The generated link looks similar to: javascript:gridWidget.editColumn(3, 3, 'PDDSectionForm', 'pdd_link', ..) The above works fine in IE.
2
1548
by: Bryan | last post by:
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object?
1
2255
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is made, the garbage collector cannot clean it up. First of all, it seems that it's best to avoid using __del__. So far, I have never used it in my...
0
2641
by: Tamer Ibrahim | last post by:
Hi, Sometimes, I got the following error message when I use ajax calendar control on some aspx pages : Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated...
2
3115
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other modules do not explicitly import TestRunError. TestRunError is raised in various places throughout the modules.
0
7524
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.