Question about ObjectDataSource.DataObjectTypeName

G

Guest

It's serious.

This is my interface:
public interface IData
{
Guid UserId { get; set; }
string IDataType { get; }
}

and my class:
public class StudentData : IData
{
private Guid userId = Guid.Empty;
public Guid UserId { ... }

private string name = "";
public string Name { ... }

private int age = 0;
public int Age { ... }
}

and the data provider
public class FormViewDataProvider
{
... // Codes to get the data

public void Set(IData i) // Update Method
{
...
}
}

now if i copy all the codes into a windows application and call it like the
following:

StudentData s = new StudentData();
FormViewDataProvider fvdp = new FormViewDataProvider();
fvdp.Set(s);

it'll work well

but if i use ObjectDataProvider and FormView and set ObjectDataProvider's
property ObjectDataTypeName = StudentData, when i update the FormView it'll
throw an exception:

ObjectDataSource 'ObjectDataSource2' could not find a non-generic method
'Set' that takes parameters of type 'StudentData'.

could somebody help me?

Stack Trace:

[InvalidOperationException: ObjectDataSource 'ObjectDataSource2' could not
find a non-generic method 'Set' that takes parameters of type 'StudentData'.]
System.Web.UI.WebControls.ObjectDataSourceView.GetResolvedMethodData(Type
type, String methodName, Type dataObjectType, Object oldDataObject, Object
newDataObject, DataSourceOperation operation) +664
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +1512
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callback) +179
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +1187
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +851
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs
e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +165

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3871
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top