Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 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


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:

         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:

      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";

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
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

All times are GMT -4. The time now is 02:13 AM.

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