I am working on an ASP.NET site to display information about authors and books. I'm working on the Author page right now and I'm having trouble getting it to display the data I want.
I'm trying to do everything with declarative controls and as little code-behind as possible.
I have a datasource on the main page that selects the Author data and provides this to a FormView. Inside the FormView is another datasource that takes the AuthorID as a parameter and selects the list of books, which is provided to a DataList.
Inside the DataList I display some limited Book information. I also want to display some child items of the Book (grandchildren of the author), for example other authors who contributed to that book, or alternative titles. I have tried using datasources in each DataList row with a parameter set to the BookID, and it works just great, but the response time is just not acceptable. Each datasource of possible several dozen is making its own call to the database and it's just too slow.
If I use code I can grab all the data in one operation and use relations in the DataBinding event (I believe) to select the data I want, but this is a bit cumbersome and I expect will cause trouble if I want to eventually use an ObjectDataSource.
Incidentally, on a display-only page I use the XMLDataSource and it works great, but I need read-write access on the Edit page.
Is there a good way to do what I'm trying to do?
Thanks,
Graham
Here's an alternative:
Instead of putting the books in a datalist you could put them in a gridview. Handle the row selected event of the gridview and programatically bind only the 'grandchild' details specific to the selected book.
|||That's probably what I'll end up doing, but I'm trying to avoid code as much as possible. In code it's pretty simple to avoid many trips to the database when fetching information, at the cost of some added complexity. I'm just looking to see if there's an equivalent way to do that declaratively.
It would be nice if you could bind to a datasource, specify a data member, and also throw in some selection criteria - filter it at the bound control, not at the datasource level. That's similar to what you can do with the XMLDataSource and XPathSelect.
|||Yeah I see what you're saying.I've never managed to getsomething like that working entirely declaratively though with asp.netcontrols. Even so, if you just do the grandchild stuff programaticallyit should only be a couple of lines of code.
You could take a look at some third party grid controls made by ComponentArt, Infragistics, Telerik etc.
No comments:
Post a Comment