Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 30th, 2008, 05:37 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default BrowseArticles.aspx Page Problem

Following through Marco's code in the book, I've reached Chapter 5: News and Article Management. There is an end-user page, BrowseArticles.aspx, that is implemented by using the ArticleListing.ascx user control. This is the exact same control that is used in the ManageArticles.aspx Admin page.

I've added the control to the BrowseArticles.aspx page, but a strange thing seems to be happening. When I navigate to BrowseArticles.aspx from ShowCategories.aspx, it displays the articles from the category specified by the CatID on the query string, which is fine. The strange occurrence is that if I then switch Categories to 'All Categories' via the drop down list, the GridView in the ArticlesListing control displays the empty message (no articles to show).

Any idea what could be happening here? This problem does not arise when I use the control in the ManageArticles.aspx Admin page.
  #2 (permalink)  
Old November 30th, 2008, 05:58 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I got it. It was that I needed a code branch in the SqlArticlesProvider class. In that class's GetArticles(bool publishedOnly, int categoryID, int startRowIndex, int maximumRows) overload, I checked for the publishedOnly value, and if it was false, I delegated to the GetArticles(int categoryID, int startRowIndex, int maxiumumRows) overload.

However, I didn't check for the case: publishedOnly is true, and categoryID is less than or equal to 0. So, what ended up happening was a call to the database querying for articles with CategoryID 0, which of course, don't exist. What the call should be is: if publishedOnly is true, and categoryID is less than or equal to 0, retrieve all published articles for all categories. Here is the fixed code:

Code:
public static List<Article> GetArticles(bool publishedOnly,
            int categoryID, int startRowIndex, int maximumRows)
        {
            if (!publishedOnly)
            {
                return GetArticles(categoryID, startRowIndex, maximumRows);
            }
            else
            {
                if (categoryID <= 0)
                {
                    return GetArticles(publishedOnly, startRowIndex, maximumRows);
                }
            }
    //otherwise, get all published articles for the specified (non-zero) category...
}
  #3 (permalink)  
Old November 30th, 2008, 07:27 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, the above code fix is applied to MB.TheBeerHouse.BLL.Articles.Article class, not the SqlArticlesProvider as I had mentioned.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem defining namespace for .aspx page pratik28 ASP.NET 2.0 Basics 0 October 26th, 2006 06:43 AM
Getting problem while running an aspx page manoj.mohanty BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 May 3rd, 2006 07:29 AM
How to pass variables from Aspx page to Asp Page jayaraj Classic ASP Basics 2 May 23rd, 2004 06:56 AM
How to pass the variables in Aspx page to Asp Page jayaraj ASP.NET 1.0 and 1.1 Basics 3 May 23rd, 2004 06:55 AM



All times are GMT -4. The time now is 04:48 PM.


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