CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeff Lynch [MVP]

Everything E-Commerce!

ASP.NET 2.0: Multiple Controls - Single DataSource

I ran across a really interesting feature of ASP.NET 2.0 that hadn't really occurred to me before now. You can bind multiple FormView and GridView controls to a single DataSource object to create some really interesting "forms". Now this is what I call "a blinding flash of the obvious"!

I have a single table DataSet returned from my BLL which contains all the information found in a single invoice including header, items and footer information. In ASP.NET 1.1, I've used "manual" binding methods to display the header and footer information and a Repeater control to display the items. A lot of HTML and a lot of code in the code-behind. In ASP.NET 2.0 I've done this using two FormView controls and one GridView control as shown in this screen-shot. Other than a Cascading Style Sheet to "format" the tables, there is no code used in the page at all.

I guess this new "declarative" programming isn't so bad after all!


Published Feb 16 2006, 08:03 PM by jlynch
Filed under:

Comments

Oskar Austegard said:

Jeff - one phrase leaps out at me from your description above: single table DataSet. You mean that you return a denormalized set of data, repeating all the header and footer info for each invoice item? Why not create a dataset with two tables, header and item?
# February 17, 2006 2:17 PM

jlynch said:

Oskar,

It was strictly a "design" decision based upon the differences between returning three SQL recordsets (header, footer and items) in a single sproc versus "denormalizing" using joins and returning one recordset with "duplicated" header and footer fields. Both ways will work just fine and frankly I'm not sure which will perform better (might be interesting to test and find out) so I reused an existing sproc from an internal SQL Reporting Services report.

Which do you think would be more "performant"?

---
Jeff
# February 17, 2006 5:52 PM

Eric Wise said:

It depends on how many rows are typically in your gridview. If you're repeating denormalized data a few times who cares. But if this was a winforms app or something that had hundreds of rows you would care. =)
# February 18, 2006 2:04 PM

Grace said:

Hi, I hope you're still reading this blogs. I'd like to know how you did it? Basically, my problem is that, I have 3 data controls - 1 RadioButtonList and 1 Gridview inside DataList. What I'd like to do is to bind all those 3 in just one data source (i prefer ObjectDataSource) so that rather than 3, it will just do one trip/retrieval to the database, and data will get populated. Can you please help me? Thanks!
# January 30, 2008 4:39 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

This Blog

Syndication