Yes, please, please, please add some detail :)
I must be missing something to the ObjectDataSource
If you did this
1. Create a ObjectDataSource where the Select calls: IList GetAllCustomers()
2. And the Update calls: UpdateCustomer(Custromer c)
[Customer has public properties for all fields]
3. Create a GridView that uses the ObjectDataSource but only displays a subset of the fields (ex: FirstName and City)
4. Use the "Edit" command and then the "Update" command.
This will happen
When the "Update" calls UpdateCustomer(Customer c),
the object passed in will only have FirstName and City values set, the others will be null!
Unfortunately, this aparently is how it is supposed to work.
Work around approaches that I have found
- Include all of the columns in the GridView.
- In the ObjectCreating and ObjectDisposing events, get/save the objects to the cache .
- Create overloaded methods for UpdateCustomer with all combinations of parameters (this can be a pain to maintain).
Any suggestions on how to know which row was edited and to end up with a complete updated object without doing a bunch of work?
I am setting DataKeyNames in the GridView and DataObjectTypeName in the ObjectDataSource.
Note: I can get it to work against the Domain object but only if all of the properties (a.k.a. fields or columns) are included in the GridView and are visible.
Thanks,
Steve
adam11235 wrote:
Hi,
You may have already figured it out by now, but you can use Domain objects directly instead of having to use seperate parameters:
You need to set the DataObjectTypeName property of the ObjectDataSource to the Domain object type.
Once you do this you do not need to explicitly define individual parameters or
use reflection.
Let me know if you need more detail.