GridView - readonly collection interaction

GridView - readonly collection interaction

Old forum URL: forums.lhotka.net/forums/t/2825.aspx


georgeb posted on Friday, May 04, 2007

I am using the csla 2.1.4 and I created a readonly collection with paging to consume it in an asp.net 2.0 app. In an asp page that I was previously using  a grid to display data using a  child collection, I change the data source with the readonly collection and made the ajustments to the grid. In debug mode I see that the data is retrieved from the database and the collection is correctly returned  in the

Protected Sub MessagesDataSource_SelectObject(ByVal sender As Object, ByVal e As Csla.Web.SelectObjectArgs) Handles MessagesDataSource.SelectObject

e.BusinessObject = RectisSecretaryII.Library.MessagesList.GetPage(e, businessObject.Id)

End Sub

The grid does not display the data.The fields are the same. Any ideas why this is happening?  

 

RockfordLhotka replied on Friday, May 04, 2007

Do the property names match exactly on the child objects? Remember that data binding does everything through reflection - taking the string property names from the grid definition and reflecting against each child object to pull out the property values.

georgeb replied on Saturday, May 05, 2007

Yes. I checked the field names and are the same. I also check the autogenerate field to true.  It still does not work.

georgeb replied on Monday, May 07, 2007

The problem remain. I refreshed the schema and again no result. I used autoregenerate columns (grid) again no result! Any ideas? (the readonly collection object has data in it).

RockfordLhotka replied on Monday, May 07, 2007

I have no ideas, sorry...

Try creating a new page, add a data control pointing to this list and binding it to a new grid - see what happens. If that works (which it should, binding to read-only collections works fine in general and people do it all the time), you can compare the aspx tags to the non-working page and maybe find the difference.

RockfordLhotka replied on Monday, May 07, 2007

One more thought though. Odds are that some exception is occurring while data binding is trying to read the data from your object. It could be a null ref thing, or one of your property get blocks has an issue, or a type mismatch or ...

But I bet that's what is happening.

georgeb replied on Tuesday, May 08, 2007

Finally!! It is partially solved! I disable the paging from the asp Gridview and it works. I noticed that the storproc returned all the records (my bug!) form the database and filled the internal readonly collection. When I used the collection in the asp page it returned (the readonly collection getlist) only the first 10 records ignoring (?) the rest entries in the list.That behavior  I guess it causes the problem.

Copyright (c) Marimer LLC