Search code examples
c#asp.netgridviewobjectdatasource

GridView and ObjectDataSource issue


Here's the problem I'm having in my asp project.

My shopping cart consists of 3 classes like the picture below.

The class Carrinho has a List of Arranjo wich by itself has a List of Product.

Now I want to display the Carrinho's list and I have a GridView whose data source is an ObjectDataSource that's associated to the Carrinho object. It should display, for now, just the Total property from Arranjo but I keep getting an empty page always. I have debugged the project and the list is definitely not empty.

What am I doing wrong?

classes picture


Solution

  • It's not regular to do that (biding a list of list<object> ) . Any way if you insist to do that you should know you need to bind a list of object to each item in GridView Row , So that item should be like List controls . otherwise you should convert your field to "ItemTemplate" and you bind by your own . Here is a good example


    Hope that helps