473,385 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FormView and ObjectDataSource - Delete doesn't work

I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything
works fine until I try the delete. The ItemDeleting event fires, so I know
it should fire my delete method, but instead I get an error: No parameterless
constructor defined for this object, and the delete method is never called.

Anyone have any ideas?
Nov 19 '05 #1
4 14308
I thought the stack trace may help on this

[MissingMethodException: No parameterless constructor defined for this
object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeTyp e 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) +261
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66

System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +127

System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod method) +38
System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteDelete(IDictionary
keys, IDictionary oldValues) +1110
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +75
System.Web.UI.WebControls.FormView.HandleDelete(St ring commandArg) +855
System.Web.UI.WebControls.FormView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +784
System.Web.UI.WebControls.FormView.OnBubbleEvent(O bject source, EventArgs
e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEven t(Object source,
EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +134

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +180
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670

Nov 19 '05 #2
Without seeing some code, I cannot be 100% sure, but here is a hint that may
help you solve the issue:

The exception is stating you do not have a default constructor on an object,
so it cannot create the object in question without parameters, which are not
supplied in this context.

Step through your code and examine the call stack at the point the exception
is thrown. This will show the point of failure.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"John Bailey" wrote:
I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything
works fine until I try the delete. The ItemDeleting event fires, so I know
it should fire my delete method, but instead I get an error: No parameterless
constructor defined for this object, and the delete method is never called.

Anyone have any ideas?

Nov 19 '05 #3
First of all, thank you for replying.

I posted the stack trace in a reply to my original message. The problem is
that the error is being generating outside of my code. I have developed
another theory, but have not had the opportunity to test it. When I first
set this up, I got an error saying that the objectdatasource could not find a
method with the parameters oringal_Key, Key. My delete method originally
only took the Key as a parameter. I changed this and then got the default
constructor error. I am thinking that they key field may be setup as
read/write when it should be readonly or something to that effect.

Does that sound plausible?

"Cowboy (Gregory A. Beamer) - MVP" wrote:
Without seeing some code, I cannot be 100% sure, but here is a hint that may
help you solve the issue:

The exception is stating you do not have a default constructor on an object,
so it cannot create the object in question without parameters, which are not
supplied in this context.

Step through your code and examine the call stack at the point the exception
is thrown. This will show the point of failure.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"John Bailey" wrote:
I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything
works fine until I try the delete. The ItemDeleting event fires, so I know
it should fire my delete method, but instead I get an error: No parameterless
constructor defined for this object, and the delete method is never called.

Anyone have any ideas?

Nov 19 '05 #4
Boy, now I feel like an idiot. My delete method was not shared, so the
objectdatasource was creating an instance of the object automatically. The
object class did not have a default constructor, so it generated an error.

I made the method shared and it works perfectly.

"Cowboy (Gregory A. Beamer) - MVP" wrote:
Without seeing some code, I cannot be 100% sure, but here is a hint that may
help you solve the issue:

The exception is stating you do not have a default constructor on an object,
so it cannot create the object in question without parameters, which are not
supplied in this context.

Step through your code and examine the call stack at the point the exception
is thrown. This will show the point of failure.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"John Bailey" wrote:
I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything
works fine until I try the delete. The ItemDeleting event fires, so I know
it should fire my delete method, but instead I get an error: No parameterless
constructor defined for this object, and the delete method is never called.

Anyone have any ideas?

Nov 19 '05 #5

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

Similar topics

2
by: Matthew Wells | last post by:
I want to delete records from the "one" table of a one to may relationship. There are no actual Access relationships set up. The "one" table has a single field PK and the "many" table has a two...
4
by: @ndy | last post by:
I import an excel sheet to access and know i won't to delete some columns. This my code that doesn't work. strSQLAlter = "ALTER TABLE ImpTableB DROP COLUMN Dossier-beheerder" DoCmd.RunSQL...
2
by: Spongebob | last post by:
Hello! I tried to use this code from Peter Torr: Foo.Attributes("onclick") = "if (confirm('delete?') == false) return false; " + Foo.Attributes("onclick") It works nomral on IE5, Windows...
10
by: Jarod | last post by:
Hey var service = this.WebServiceURL +"/SessionFun?sessionID="+ this.SessionID ; var xmlDoc=document.implementation.createDocument("", "", null); try {
0
by: zhengmao | last post by:
I have one store procedure, which works fine in SQL Analyzer when I test it out, but doesn't work when I call it in web application. the problem is it doesn't insert last line, and the problem is...
2
by: ruthiefy | last post by:
Hi, I am new to ASP.NET and I started working with 2005. I opened a new project and in the Default.aspx Web Form I clicked the "Design" button in the bottom of the screen so I can edit the...
1
by: Swinky | last post by:
I have added code to delete a record (and records in related tables) in the OnClick property: MsgBox "Confirm delete. Once you confirm, record will no longer exist.", vbOKCancel strSQL =...
0
by: cmrchs | last post by:
Hi, I want to bind an ObjectDataSource to a VS.NET Dataset but it doesn't work. here's what i do: - I add a new DataSet (ProductsDs) to the App_Code folder of the web- project - I run the...
0
by: Bobby Edward | last post by:
I'm trying to filter an objectdatasource based on words in a textbox. Here's how I'm doing it... With odsProjects .FilterParameters.Clear() .FilterExpression = "ProjectTitle LIKE %{0}%" Dim p...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.