Question about ObjectDataSource.DataObjectTypeName



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

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

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'.]
type, String methodName, Type dataObjectType, Object oldDataObject, Object
newDataObject, DataSourceOperation operation) +664
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
eventArgument) +165

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
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