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 December 15th, 2009, 03:51 PM
Authorized User
 
Join Date: Jun 2009
Posts: 32
Thanks: 17
Thanked 0 Times in 0 Posts
Default EnsureValidSortExpression method

hi

The following questions all refer to the EnsureValidSortExpression method ( page 397 ):


a) I assume the reason we replace substring “title” with “tbh_posts.title” is so that SQL server processing our query doesn’t get confused whether we are referring to tbh_Forums.Title or to tbh_Post.Title column:

Code:
         if (sortExpr.StartsWith("title"))
              sortExpr = sortExpr.Replace("title", "tbh_posts.title");


b) For each of the GridView’s columns that enable sorting, EnsureValidSortExpression method checks whether supplied sortExpression parameter equals to one of three kinds of strings à “column_name” or “column_name desc” or “column_name asc”. GridView automatically appends “ASC" or “DESC” to a “column_name”, so I don’t see the point in EnsureValidSortExpression also checking whether supplied parameter equals to “column_name” type of string, since as far as I know, sortExpression string will always also contain “ASC” or “DESC” value?! Thus, wouldn’t the following code be just as efficient:


Code:
      protected virtual string EnsureValidSortExpression(string sortExpression)
        { 
  ... 
   
  if (!sortExpr.Equals("lastpostdate asc") && !sortExpr.Equals("lastpostdate desc") &&
              !sortExpr.Equals("viewcount asc") && !sortExpr.Equals("viewcount desc") &&
              !sortExpr.Equals("replycount asc") && !sortExpr.Equals("replycount desc") &&
              !sortExpr.Equals("addeddate asc") && !sortExpr.Equals("addeddate desc") &&
              !sortExpr.Equals("addedby asc") && !sortExpr.Equals("addedby desc") &&
              !sortExpr.Equals("title asc") && !sortExpr.Equals("title desc") &&
              !sortExpr.Equals("lastpostby asc") && !sortExpr.Equals("lastpostby desc"))
           {
              sortExpr = "lastpostdate desc";
           }
   
  ...
thanx





Similar Threads
Thread Thread Starter Forum Replies Last Post
About Method VeradisSanthanam ASP.NET 2.0 Basics 1 June 19th, 2007 06:52 AM
method amit_p_patel VB How-To 2 May 25th, 2007 01:46 AM
Why is this method placed in filip BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 August 25th, 2006 09:40 PM
Best method rastham SQL Server 2000 2 February 16th, 2006 12:59 AM
Method StanArtis BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 December 6th, 2004 06:09 AM





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