Having said all good about ObjectDataSource, it is time disclose a fact. The ObjectDataSource cannot use methods that accept an "Object" as a parameter to Update, Delete or Insert. See the picture below

In the picture, you can see that the Update method is configured to UpdatePerson(Person person). However the runtime will error out with the following message.
"ObjectDataSource 'PersonDataSource' could not find a non-generic method 'UpdatePerson' that has parameters: FirstName, LastName. "
The cheat to this is to write a wrapper method around the UpdatePerson to accept individual attributes and use it. See code snippet below.
Public void UpdatePerson(string FirstName,string LastName)
{
Person p = PersonDAL.GetByName("John");
p.FirstName = FirstName;
p.LastName = LastName;
p.UpdatePerson(p);
}
0 comments:
Post a Comment