What is the best way to create a GridView showing summary sales data?

frtelook

New Member
I have developed an eCommerce application in C# and ASP.Net. For the Admin users "dashboard" landing page, I would like to give them a GridView that shows them the total sales dollar amount for a couple different time ranges, these would be my columns (ie last day, last week, last month, last year, total ever). I would like to give these values for orders that are in different status' (ie complete, paid but not shipped, in progress). Something similar to this:\[code\]|OrderStatus|Today|LastWeek|LastMonth||Processed |$10 |$100 |$34000 ||PaidNotShip|$4 |$12 |$45 |\[/code\]My question: What is the best/most efficient way to do this? I know that I could write separate SQL statements and union them together and bind the gridview to a sqldatasource: \[code\](select amountForYesterday, amountForLastWeek from sales where orderStatus = processed)UNION (select amountForYesterday, amountForLastWeek from sales where orderStatus = paidnotshipped) \[/code\]But that seems like a pain and very inefficient, since I would effectively be writing a separate query for each value.I could also do this in the .cs page behind on load and programmatically populate the grid view row by row. This GridView would only show information for the user's specific organization, so it would have to filter based on that as well.I'm kind of at a loss as to how to do this without writing a massive query and continually hitting that query and database each time the page is viewed.Any ideas?
 
Back
Top