Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview/objectdatasource can not update/delete complex objects?

Status
Not open for further replies.

crazyitguy

IS-IT--Management
Jul 20, 2006
36
US
is it true that gridview/objectdatasources can not update/delete complex custom business objects?

like:
Code:
public class Order
{
private int _orderid;
private string _somestring;
private Customer _customer;
public Order()
{
_orderid = 0;
_somestring = "";
customer = new Customer ();
}
//...get/set methods
}

I am binding a gridview to an objectdatasource which itself binds to a list<Order>. When I try to update, _orderid and _somestring are filled properly, but _customer is empty even though the user selects the customer in the gridview when updating.

thanks
 
not true.

complex custom business objects are still written by you, so if you understand it, its not that complex. You might have written an in depth procedure, however asp.net can handle most that is thrown at it, if written properly.

Using a term like complex custom business objects shouldnt be so scary, it wouldnt be easy if it was complex, it wouldnt be custom if you didnt write it, and whats an app without a business object?

unless we arent seeing your full example here...

customer = new Customer ();

should be

_customer = new Customer ();

that should have generated a runtime error.
 
I didn't mean to incinuate that I do not know how to write "complex custom business objects". I have written many.When I say " complex custom business objects" I meant an obect that has a handle on another object.

I was just giving example code above, its not the actual code I wrote. That mistakewith the customer object was a typo.

If I want to have an update column in the gridview, it seems the gridview can not send a "complex custom business objects" to the objectdatasource update method.

For example I have a gridview that displays all orders along with the customer who ordered it. On a particular order, I want to change the customer that the order has a handle on(obviously, I wouldn't do this in real life, just an example). I click "Edit" in the gridview. I change the dropdownlist to point to another customer(The dropdownlist itself is bound to another objectdatasouorce).I click "update". The update does not work....I lose the customer values. I can change any simple types such as _orderid.


It seems that this extendedobjectdatasource( ) user control makes up for this limitation (if it is a limitation).

My question is: is there a limitation here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top