Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2007, 03:47 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Separation between ui and bll

Hi,

I'm developing a site that uses this book as a basis for separating the different layers.

I have a page with an ObjectDatasource and a Gridview connected to it using proper BLL and DAL classes to update rows in the database. Now, every time I do an update I want to display a message to the user using a label. By using the gridview's RowUpdated action in the code-behind file, I can get the number of rows affected by using e.AffectedRows (if it was working properly).
Code:
if (e.AffectedRows == 1)
   lblFeedback.Text = "Row updated";
else if (e.AffectedRows < 1)
   lblFeedback.Text = "Oooops";

It will always return "Oooops", but the database is still updated. Why isn't this working?


Another thing, assuming that this is working: would this be proper separation of the layers, or should I set the label's text in the BLL? If so, how can one do that?
 
Old July 1st, 2007, 10:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'd guess you'll get an exception if an update doesn't work. I wouldn't go out of my way to test myself. Just make sure you have page level and global error handlers set up.

You must never set the value of any UI element in the BLL or DAL layers! That breaks the fundamental reason for having a separation of tiers.

Eric

 
Old July 11th, 2007, 07:22 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hmm... ok.

But how can the UI know what error message to output? Say that I have an image that is connected to a page in a database. If I try to delete the image from the database, the UI should say (something like this): "Error: image cannot be deleted because it is in use on a page."

A solution for this is to have a custom made link button and from that's onclick method try call the BO calling the DAL. The problem is that by doing this I lose the connection that the datagrid, or a formview, and the objectdatasource has, meaning that I have to use the FindControl() method to find every control, get the value/text from each control, and from that create an object to send to the BO and DAL. It is a lot of work....

Is there a way to get the messages from the BLL to the UI without doing this?
 
Old July 11th, 2007, 08:55 AM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

"But how can the UI know what error message to output?"

If you use ("try" and throw exception) on your DAL you can see what error you receive!

But remember to log this error and don't show it to user is visiting your page.

If you want to made an update, use your DAL to return True if update was made, and False case else... (Don't forget throw exception)
The BLL continue to retrieve True or false from the DAL and send it to the UI.

If BLL send true to the UI you set lblFeedback.Text = "Row updated";
If BLL send false to the UI you set lblFeedback.Text = "Ooops";

If any error occur in BLL or DAL like ("image is in use, can´t find table, can't find database, etc) it is automatically shown (if you do the right "throw exception everywhere this type of error may occur)








Similar Threads
Thread Thread Starter Forum Replies Last Post
Category BLL/UI Problem mashour BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 November 25th, 2008 06:32 PM
Profile in BLL Faith ASP.NET 2.0 Professional 3 August 18th, 2008 10:57 AM
DAL to BLL rodmcleay LINQ 3 June 2nd, 2008 12:15 PM
Profile in BLL Faith BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 14th, 2006 03:57 AM
Tier separation djm2cmu BOOK: ASP.NET Website Programming Problem-Design-Solution 2 February 29th, 2004 10:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.