B
bednarz.thomas
I have the following business Object(s):
public class ParentObject
{
public ParentObject(string somestring)
{
...-
}
....
}
public class MyBusinessObject : global:arentObject
{
public MyBusinessObject (string somestring)
: base(somestring)
{
...
}
// some properties and other stuff
}
On a page I have defined a ObjectDataSource for MyBusinessObject. 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 MyBusinessObjectDS_Creating(object sender,
ObjectDataSourceEventArgs e)
{
BO_MyBusinessObject mbo = new BO_MyBusinessObject(somestring);
e.ObjectInstance = mbo;
}
This works just fine!
PROBLEM is the update method!
In my <aspetailsView> control I have defined a OnItemUpdating
EventHandler. This gets calls. After that I get the following
exception:
[MissingMethodException: No parameterless constructor defined for this
object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
fillCache) +103
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
skipVisibilityChecks, Boolean fillCache) +268
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject(Type
dataObjectType, IDictionary inputParameters) +39
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +1294
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.DetailsView.HandleUpdate(String
commandArg, Boolean causesValidation) +1152
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e,
Boolean causesValidation, String validationGroup) +440
I also have a Updating handler on my ObjectDataSource. 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
public class ParentObject
{
public ParentObject(string somestring)
{
...-
}
....
}
public class MyBusinessObject : global:arentObject
{
public MyBusinessObject (string somestring)
: base(somestring)
{
...
}
// some properties and other stuff
}
On a page I have defined a ObjectDataSource for MyBusinessObject. 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 MyBusinessObjectDS_Creating(object sender,
ObjectDataSourceEventArgs e)
{
BO_MyBusinessObject mbo = new BO_MyBusinessObject(somestring);
e.ObjectInstance = mbo;
}
This works just fine!
PROBLEM is the update method!
In my <aspetailsView> control I have defined a OnItemUpdating
EventHandler. This gets calls. After that I get the following
exception:
[MissingMethodException: No parameterless constructor defined for this
object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
fillCache) +103
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
skipVisibilityChecks, Boolean fillCache) +268
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject(Type
dataObjectType, IDictionary inputParameters) +39
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +1294
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.DetailsView.HandleUpdate(String
commandArg, Boolean causesValidation) +1152
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e,
Boolean causesValidation, String validationGroup) +440
I also have a Updating handler on my ObjectDataSource. 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