ASP.NET GridView bound to custom business objs, with sorting and filtering - CSLA framework?

ASP.NET GridView bound to custom business objs, with sorting and filtering - CSLA framework?

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


RBrown posted on Thursday, November 16, 2006

Hello from a CSLA newbie,

Originally, I was looking to enable sorting and filtering in my Generic Collection class by whatever means necessary (implementing BindingList, etc.) so that I could easily bind these collections (of my biz objects) to GridViews in my Web apps and achieve sorting and filtering with relative ease.  Most of the code that I ran across regarding sorting and filtering seems to pertain to WinForms and not ASP.NET. 

However, I eventually ran across the CSLA .Net framework and was impressed by funtionality incorporated into the classes.  So, rather than reinvent the wheel, I am now considering changing my development approach to utilize the CSLA framework and was wondering three things:

1 - How easy is it to implement the CSLA .Net framework into my apps.  Do I just, add the necessary references, inherit my business objects and collections from CSLA classes, and away I go?

2 - Is there a generic collection class interface or implementation in the framework that will allow me to load collections of my custom business objects, bind to an ASP.NET GridView, and then be able to sort and filter with ease?  If so, could I get a 10,000 foot overview how this is done? 

As it stands now, I'm calling a method in my common framework that transforms the business obj collection to a DataTable that is then bound to the GridView.   The DataTable makes it much easier to sort as it supports (for free) all the necessart interfaces for doing so without me having to code these features.  However, this obviously comes at a performance cost and I would be much better off if this was built into the collection class in the first place.  I also wire up the GridView_Sorting event to handle the sorting, which basically creates a DataView on the grid's DataTable and calls the DataView's Sort method and rebinds the view to the grid.  I feel like I'm running around in circles here just to get sorting and filtering to work with custom business objects bound to ASP.Net GridViews.  I've got to be doing this wrong :(

Any enlightenment will be much appreciated..thanks a ton!

Randy

RBrown replied on Friday, November 17, 2006

Uhhh...ok, I admit it.  Those were dumb questions (hence, no replies).  Wink [;)]

After reading Barry's overview article, I'm blown away at what the CSLA framework offers.  And though there will be a pretty large learning curve, I think I'm committed to the task as the benefits in this case will most certainly outweigh the costs.  Seems like everything I've ever dealt with or considered handling in my Business Objects has been addressed in CSLA.  Truely amazing stuff.

I went out and bought the book...hopefully my next question won't be so ignorant!

RockfordLhotka replied on Friday, November 17, 2006

I don't think the questions were dumb Wink [;)], but it is true that CSLA .NET is a fairly comprehensive framework in some ways, and so there is more to it than just inheriting from the base classes and going from there. Reading the book should give you a much better understanding of my rationale for building the framework and how to best use it.

Regarding sorting and filtering, the SortedBindingList<T> and FilteredBindingList<T> (in 2.1.1) classes should help you achieve your immediate goal of sorting/filtering data on your page. Keep in mind however, that filtering is often best done in the database rather than on the web server - but at least with these classes you have the flexibility to choose.

Copyright (c) Marimer LLC