<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>sano the super geek</title><link>http://blogs.msdn.com/b/csano/</link><description>the endeavors of a professional geek at microsoft.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Microsoft Build Sidekick</title><link>http://blogs.msdn.com/b/csano/archive/2006/07/13/664832.aspx</link><pubDate>Thu, 13 Jul 2006 22:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:664832</guid><dc:creator>csano</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=664832</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2006/07/13/664832.aspx#comments</comments><description>The folks at Trivium Technologies have released the first version of their &lt;a href="http://www.attrice.info/msbuild/index.htm"&gt;MSBuild Sidekick&lt;/a&gt;, a GUI front end to MSBuild. Even though this tool probably cannot replace the productivity that I can currently attain by taking advantage of the Intellisense support in Visual Studio, I think it would have been a great asset when I was first starting out with MSBuild. It's also free, so there's no harm in checking it out.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=664832" width="1" height="1"&gt;</description></item><item><title>Custom Windows Forms Controls: ColorPicker.NET, Part 2</title><link>http://blogs.msdn.com/b/csano/archive/2006/06/29/651678.aspx</link><pubDate>Fri, 30 Jun 2006 06:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:651678</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=651678</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2006/06/29/651678.aspx#comments</comments><description>&lt;p&gt;It took them a long time, but the folks at &lt;a href="http://msdn.microsoft.com"&gt;MSDN&lt;/a&gt; finally got around to publishing the second part of my ColorPicker.NET &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/colorpick2.asp"&gt;article&lt;/a&gt;. In this one, I cover the implementation details for the scrolling magnifying glass control and the zoom panel that is used to magnify the captured portion of your desktop.&lt;/p&gt;

&lt;p&gt;You can get the source code for v.0.2 from the ColorPicker.NET &lt;a href="http://workspaces.gotdotnet.com/colorpicker"&gt;workspace&lt;/a&gt;. I haven't had the chance to recompile it in .NET v.2.0 yet, although I do have plans to continue developing the tool on that platform.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=651678" width="1" height="1"&gt;</description></item><item><title>Changing the default sort order of your sortable columns on the ASP.NET GridView</title><link>http://blogs.msdn.com/b/csano/archive/2006/06/29/651310.aspx</link><pubDate>Fri, 30 Jun 2006 06:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:651310</guid><dc:creator>csano</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=651310</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2006/06/29/651310.aspx#comments</comments><description>&lt;p&gt;One of the great things about the new ASP.NET GridView control is that it allows you to implement column field sorting with relative ease, at least in comparison to what you would have had to do to attain similar functionality in earlier versions. There are a plethora of articles and tutorials out there that lead you through this process, but one thing that most, if not all, of these are lacking is some kind of hint of how to override the default sorting order of your sortable columns. Since this was a problem that I had to solve recently and given the number of times I’ve seen the question being asked (and unanswered) across various forums and newsgroups, I figured I’d take some time to share my solution with the community. &lt;/p&gt;

&lt;p&gt;This entry assumes that you have a good understanding of how sorting works in the DataGrid. If you don’t, I would suggest that you take some time to do so before continuing. There is no download, but I provide enough code for you to be able to implement this solution on your own grid.&lt;/p&gt;

&lt;p&gt;The GridView control raises two sort-related events when the user clicks on a link button in the header of any columns that has its CommandName property set to Sort. The Sorting event is raised before the GridView handles the sort operation and the Sorted event is raised after the sorting has completed and data has been bound to the grid.&lt;/p&gt;

&lt;p&gt;The Sorting event is of particular interest to us. By handling this event, we have the opportunity to manipulate the sort data before the grid hands it to the underlying data store (usually managed by an instance of ObjectDataSource) and asks for the data to be manipulated in a form that conforms to the sorting rules that it has established.&lt;/p&gt;

&lt;p&gt;When the event is handled, we receive a reference to a GridViewSortEventArgs object which contains properties that contain values that we are interested in. The first is the SortExpression property, which, in the simplest of situations, contains the name of the field that is to be sorted. The second is the read-only SortDirection property which defines the order in which the data will be sorted. This actually serves no purpose in this space other than to provide assistance in identifying the eventuating sort direction.&lt;/p&gt;

&lt;p&gt;Once the handler has completed its scope of execution, if the sort has not been cancelled by setting the Cancel property of the GridViewSortEventArgs object to true, an instance of DataSourceSelectArguments is created and the final sort expression is defined. The pertinent value is essentially a concatenation of the SortExpression value and the SQL equivalent of the SortDirection value if it is defined as SortDirection.Descending. In other words, given a column named (and sort expression defined as) Rating and a SortDirection value of SortDirection.Descending, the ultimate sort expression will be “Rating DESC.” If the SortDirection value is SortDirection.Ascending, the expression would be restricted to only the defined SortExpression, which would be “Rating.”&lt;/p&gt;

&lt;p&gt;Now that we have attained this understanding, let’s take a look at how this can be manipulated to reverse the default sorting order.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SearchResultsView_OnSorting( &lt;span class="kwrd"&gt;object&lt;/span&gt; sender, GridViewSortEventArgs e ) {
  e.SortExpression = e.SortExpression + " DESC"
}&lt;/pre&gt;

&lt;p&gt;In the above code block, I’ve overridden the SortExpression value that was captured at the time that the event was raised. Instead of the values in the column being sorted in ascending order, which, again, is the default, the expression has been defined as a concatenation of the original sort expression and DESC. Once the event has been handled, the updated SortExpression will be parsed and the SortDirection property on the grid will be updated as appropriate to match the order that you specified in the expression. What this means is that if the next sort is done on the same column, the SortDirection value will be SortDirection.Ascending instead of SortDirection.Descending.&lt;/p&gt;

&lt;p&gt;The code would work great if you wanted the default (and only) sorting order of each of the sortable columns in your grid to be descending. This is clearly not the desirable outcome. Since we only want this exception to apply to the Rating expression, we’ll add some code that checks for this expression before overriding its default sort.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SearchResultsView_OnSorting( ... ) {
  &lt;span class="kwrd"&gt;if&lt;/span&gt; ( e.SortExpression.Equals( &lt;span class="str"&gt;"Rating"&lt;/span&gt; ) ) {
    e.SortExpression = e.SortExpression + " DESC";         
  }
}
&lt;/pre&gt;

&lt;p&gt;We still want the contents of the Rating column to be sorted in ascending order, but only after the column has previously been sorted in descending order. To clarify, there are two different scenarios that we need to cover:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sorting the Rating column when it's already in descending order should result in an ascending sort.&lt;/li&gt;
&lt;li&gt;If a different column is sorted after the Rating column has been sorted, regardless of its order, the first sort of the Rating column afterwards should be descending.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The implementation is actually relatively simple. All we need to do is stash away the most recent expression in a state bag (ViewState) and load and compare it when the next Sorting event is handled. The following code demonstrates how we first check to make sure that the current sort expression is the Rating expression, then we check the value stored in the PreviousSortExpression key in ViewState to see if it was used in the previous sort. If it was, then the sorting is done based on the current SortDirection, otherwise it's forced to descending order.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;
&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SearchResultsView_OnSorting( ... ) {

  &lt;span class="kwrd"&gt;string&lt;/span&gt; originalExpression = e.SortExpression;

  &lt;span class="kwrd"&gt;if&lt;/span&gt; ( e.SortExpression.Equals( &lt;span class="str"&gt;"Rating"&lt;/span&gt; ) ) {

      &lt;span class="kwrd"&gt;if&lt;/span&gt; ( ViewState[ &lt;span class="str"&gt;"PreviousSortExpression"&lt;/span&gt; ] == &lt;span class="kwrd"&gt;null&lt;/span&gt; || 
           !ViewState[ &lt;span class="str"&gt;"PreviousSortExpression"&lt;/span&gt; ].ToString().Equals( originalExpression ) ) {
            
        e.SortExpression = e.SortExpression + &lt;span class="str"&gt;" DESC"&lt;/span&gt;;
        
      } 

   }

  ViewState[ &lt;span class="str"&gt;"PreviousSortExpression"&lt;/span&gt; ] = originalExpression;

}
&lt;/pre&gt;

&lt;p&gt;That does it. Happy Sorting!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=651310" width="1" height="1"&gt;</description></item><item><title>Incorrect syntax near '[Insert Arbitrary Column Name]'</title><link>http://blogs.msdn.com/b/csano/archive/2006/01/18/514429.aspx</link><pubDate>Wed, 18 Jan 2006 21:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:514429</guid><dc:creator>csano</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=514429</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2006/01/18/514429.aspx#comments</comments><description>&lt;P&gt;I ran into a rather mysterious error when working with some SQL code today. &lt;BR&gt;&lt;FONT face="Courier New" color=#ff0000 size=2&gt;Incorrect syntax near '[Insert Arbitrary Column Name]'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Before I get to the nuts and bolts&amp;nbsp;of the problem, we'll start with some background details. &lt;/FONT&gt;The stored procedure that I was working on was broken down into two disparate parts. The first part had two different queries encapsulated in&amp;nbsp;try/catch blocks (also a new feature of SQL 2005 in case you weren't already aware). The query in the try block attempts to perform a full-text search using keywords that are provided through one of the stored procedure parameters. In the case of failure (i.e. if the keyword parameter is NULL), control in the try block&amp;nbsp;is interrupted and restored in the catch block where a query&amp;nbsp;is performed against the table, retrieving all of the records that exist.&amp;nbsp;Matching records are stored in a temporary table for processing in the latter part of the procedure. In the second part, the records in the temporary table are filtered further according to various attributes&amp;nbsp;that are defined through the procedure's parameter list. Several aggregations and computations also occur here. The &lt;/P&gt;
&lt;P&gt;I was attempting to leverage the new&lt;FONT face="Courier New" size=2&gt; ROW_NUMBER()&lt;/FONT&gt; function while in the process of updating a stored procedure to provide custom pagination support for one of our DataGridViews. This function provides a means for providing a sequential series of row numbers for a partition of a result set. In other, much simpler terms, paging assistance.&amp;nbsp;This allows you to conveniently define a range of results that you would like to retrieve from the data store. For example, the following SQL code retrieves the ID, first name, last name and row number&amp;nbsp;of the first 10 records in the Person.Contact entity in the AdventureWorks&amp;nbsp;database.&lt;/P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;SELECT&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;TOP&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; 10 ContactId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; FirstName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; LastName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; ROW_NUMBER&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;()&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;OVER&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ORDER&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;BY&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; ContactId &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ASC&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; RowNumber &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; Person&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;Contact &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WHERE&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; MiddleName &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;IS&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;NOT&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;NULL&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;This results in the following table:&lt;/P&gt;
&lt;TABLE cellPadding=2 border=2&gt;

&lt;TR&gt;
&lt;TD&gt;ContactId&lt;/TD&gt;
&lt;TD&gt;FirstName&lt;/TD&gt;
&lt;TD&gt;LastName&lt;/TD&gt;
&lt;TD&gt;RowNumber&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;Gustavo&lt;/TD&gt;
&lt;TD&gt;Achong&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;Catherine&lt;/TD&gt;
&lt;TD&gt;Abel&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;Kim&lt;/TD&gt;
&lt;TD&gt;Abercrombie&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;Humberto&lt;/TD&gt;
&lt;TD&gt;Acevedo&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;Pilar&lt;/TD&gt;
&lt;TD&gt;Ackerman&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;Frances&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;Margaret&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;Carla&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;9&lt;/TD&gt;
&lt;TD&gt;Jay&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;Ronald&lt;/TD&gt;
&lt;TD&gt;Adina&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;Take note of how the RowNumber column lists integers in sequential order pertaining to the designated ordering of the ContactId column of the individual entities of the Person.Contact entity (&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;ROW_NUMBER&lt;FONT color=#808080&gt;()&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;OVER&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;ORDER&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;BY&lt;/FONT&gt;&lt;FONT color=#000000&gt; ContactId &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;ASC&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New"&gt;)&lt;/FONT&gt;)&lt;/FONT&gt;&lt;/FONT&gt;. It's not obvious in the table above, but because the numbers in RowNumber are sequential, it becomes even more simpler to define a range of records that you'd like returned without having to worry about&amp;nbsp;mangling your code with convoluting logic&amp;nbsp;that attempts to define a range using non-sequential identity values. (Think about how you would&amp;nbsp;define a range if ContactIds 3 and 7 were deleted -- this is discussed later on).&lt;/P&gt;
&lt;P&gt;The BETWEEN operator helps you define a range. It requires that you supply a set of two operands, one of which defines the column where the data resides and the other which defines the lower and upper bound of the range that will be defined by the operator when the statement is executed. A very basic example showing how you can retrieve the records of contacts whose ContactID is between&amp;nbsp;4 and&amp;nbsp;7 follows:&lt;/P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;SELECT&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; ContactId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; FirstName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; LastName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; ROW_NUMBER&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;()&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;OVER&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ORDER&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;BY&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; ContactId &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DESC&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; RowNumber &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; Person&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;Contact &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WHERE&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;FONT color=#ff0000&gt;ContactId &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT size=2&gt;BETWEEN&lt;/FONT&gt;&lt;FONT size=2&gt; 4 &lt;/FONT&gt;&lt;FONT size=2&gt;AND&lt;/FONT&gt;&lt;FONT size=2&gt; 7&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;TABLE cellPadding=2 border=1&gt;

&lt;TR&gt;
&lt;TD&gt;ContactId&lt;/TD&gt;
&lt;TD&gt;FirstName&lt;/TD&gt;
&lt;TD&gt;LastName&lt;/TD&gt;
&lt;TD&gt;RowNumber&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;Humberto&lt;/TD&gt;
&lt;TD&gt;Acevedo&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;Pilar&lt;/TD&gt;
&lt;TD&gt;Ackerman&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;Frances&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;Margaret&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;You can now see that the ContactId and RowNumber values are no longer in sync. Again, this is because the row numbers are generated sequentially based on a partition of the greater result set. In this case, the partition is the range of records in which the ContactId value is between 4 and 7 inclusive.&lt;/P&gt;
&lt;P&gt;So, back to the issue that I encountered. After writing&amp;nbsp;some sample code, it was clear that in order to define a range, I would need to&amp;nbsp;use the BETWEEN operator, providing the derived RowNumber&amp;nbsp;column and my desired range.&amp;nbsp;It sounded simple enough, so I wrote the following code to evaluate my understanding of the potential solution.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff&gt;SELECT&lt;/FONT&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;ContactId, &lt;BR&gt;&amp;nbsp; FirstName, &lt;BR&gt;&amp;nbsp; LastName, &lt;BR&gt;&amp;nbsp; ROW_NUMBER() &lt;FONT color=#0000ff&gt;OVER &lt;FONT color=#000000&gt;(&lt;/FONT&gt; ORDER BY&lt;/FONT&gt; ContactId &lt;FONT color=#0000ff&gt;ASC&lt;/FONT&gt; ) &lt;FONT color=#0000ff&gt;AS &lt;/FONT&gt;RowNumber &lt;BR&gt;&lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt; Person.Contact&lt;BR&gt;&lt;FONT color=#0000ff&gt;WHERE&lt;/FONT&gt; RowNumber &lt;FONT color=#808080&gt;BETWEEN&lt;/FONT&gt; 1 &lt;FONT color=#808080&gt;AND&lt;/FONT&gt; 5&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;When I executed the code, I encountered the error message mentioned at the beginning of this entry.&lt;/P&gt;&lt;FONT face="Courier New" color=#ff0000 size=2&gt;
&lt;P&gt;Invalid column name 'RowNumber'.&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;I was dumbfounded. The error message was of absolutely no assistance. This was one of those moments where I just knew that my inexperience with SQL would result in a really painful&amp;nbsp;(but eventually beneficial) journey. I traversed several different pages of the documentation in an attempt to figure out why what seemed like a relatively simple SQL query had gone haywire on me. My office mate jumped in after a while and after several different searches, was able to find something that stated that because RowNumber was a derived column, it could not be referenced in the search expression. I thought that this was kind of weird, but assured myself that it made sense. The next step was to try and figure out a way to use the values generated by &lt;FONT face="Courier New" size=2&gt;ROW_NUMBER()&lt;/FONT&gt; to define a range.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I decided to continue working with the Persons.Contact entity in the AdventureWorks database, writing script that emulated the stored procedure that I was attempting to modify. First, I needed to create a temporary table that would house preliminary results, just like the table in my stored procedure that contains the results of the full-text search.&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;DECLARE&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; @Results &lt;FONT color=#0000ff&gt;TABLE&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;BR&gt;&amp;nbsp; ContactId &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; FirstName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;FONT color=#808080&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; MiddleName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;FONT color=#808080&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&amp;nbsp; LastName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New" size=2&gt;) &lt;/FONT&gt;&lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;I then wrote the query that would populate the temporary table with data. This is relatively similar to the query that I used earlier with the addition of the MiddleName column which is used to refine the result set in the next query.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;INSERT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;FONT color=#0000ff&gt;INTO&lt;/FONT&gt; @Results&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;SELECT TOP&amp;nbsp;&lt;FONT color=#000000&gt;10&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; ContactID&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; FirstName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; MiddleName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&amp;nbsp; LastName&lt;/FONT&gt; &lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt; Person&lt;FONT color=#808080&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;Contact&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;P&gt;The final query returns a result set containing contacts that have middle names.&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; ContactId&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; FirstName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; MiddleName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&amp;nbsp; LastName &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; @Results&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;WHERE&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; MiddleName &lt;FONT color=#808080&gt;IS&lt;/FONT&gt; &lt;FONT color=#808080&gt;NOT&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New" size=2&gt;NULL&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT color=#000000&gt;My initial approach to the problem was altering the temporary table&amp;nbsp;to add&amp;nbsp;a RowNumber field and populate this&amp;nbsp;column in the initial query as such:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;INSERT&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;INTO&lt;/FONT&gt;&lt;FONT color=#000000&gt; @Results&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#000000&gt;&amp;nbsp; ContactID&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&amp;nbsp; FirstName&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&amp;nbsp; MiddleName&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp; LastName&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" color=#ff0000 size=2&gt;ROW_NUMBER() OVER ( ORDER BY ContactId ASC ) AS RowNumber &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt;&lt;FONT color=#000000&gt; Person&lt;/FONT&gt;&lt;FONT color=#808080&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000000&gt;Contact&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE cellPadding=2 border=1&gt;

&lt;TR&gt;
&lt;TD&gt;ContactId&lt;/TD&gt;
&lt;TD&gt;FirstName&lt;/TD&gt;
&lt;TD&gt;MiddleName&lt;/TD&gt;
&lt;TD&gt;LastName&lt;/TD&gt;
&lt;TD&gt;RowNumber&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;Gustavo&lt;/TD&gt;
&lt;TD&gt;NULL&lt;/TD&gt;
&lt;TD&gt;Achong&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;Catherine&lt;/TD&gt;
&lt;TD&gt;R.&lt;/TD&gt;
&lt;TD&gt;Abel&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;Kim&lt;/TD&gt;
&lt;TD&gt;NULL&lt;/TD&gt;
&lt;TD&gt;Abercrombie&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;Humberto&lt;/TD&gt;
&lt;TD&gt;NULL&lt;/TD&gt;
&lt;TD&gt;Acevedo&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;Pilar&lt;/TD&gt;
&lt;TD&gt;NULL&lt;/TD&gt;
&lt;TD&gt;Ackerman&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;Frances&lt;/TD&gt;
&lt;TD&gt;B.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;Margaret&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;Carla&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;9&lt;/TD&gt;
&lt;TD&gt;Jay&lt;/TD&gt;
&lt;TD&gt;NULL&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;Ronald&lt;/TD&gt;
&lt;TD&gt;L.&lt;/TD&gt;
&lt;TD&gt;Adina&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;It was immediately obvious that I was going to have a problem after I ran my second query. Take another look at the query. Notice how&amp;nbsp;I'm filtering by records that contain middle names (or at least initials). When this second query runs, I'm given a result set that contains row numbers that are out of order.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;TABLE cellPadding=2 border=1&gt;

&lt;TR&gt;
&lt;TD&gt;ContactId&lt;/TD&gt;
&lt;TD&gt;FirstName&lt;/TD&gt;
&lt;TD&gt;MiddleName&lt;/TD&gt;
&lt;TD&gt;LastName&lt;/TD&gt;
&lt;TD&gt;RowNumber&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;Catherine&lt;/TD&gt;
&lt;TD&gt;R.&lt;/TD&gt;
&lt;TD&gt;Abel&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;Frances&lt;/TD&gt;
&lt;TD&gt;B.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;Margaret&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;Carla&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;Ronald&lt;/TD&gt;
&lt;TD&gt;L.&lt;/TD&gt;
&lt;TD&gt;Adina&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;At this point, I was even more confused. I could think of a few different approaches that could work here (views, cross-applying a UDF, creating a second temporary table,&amp;nbsp;et al), but was not sure which one would be the most beneficial performance-wise, especially when dealing with large volumes of data. I headed back to the documentation, this time focusing on derived columns, hoping to find some kind of hint that would explicate how to reference this type of column in a search expression. Right under &lt;EM&gt;derived columns&lt;/EM&gt; in the indexed view was &lt;EM&gt;derived tables &lt;/EM&gt;(or virtual tables). After reading some more on this, I discovered that derived tables are, in their simplest form,&amp;nbsp;SELECT statements&amp;nbsp;in the FROM clause that forms a table referred by an alias that can be used by the outer select.&amp;nbsp;To me, this meant that I could move the &lt;FONT face="Courier New" size=2&gt;ROW_NUMBER()&lt;/FONT&gt; logic from the first query to the second query and then utilize derived tables to access the value of RowNumber.&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; &lt;FONT color=#808080&gt;*&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt; &lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp; SELECT&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ContactId&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MiddleName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROW_NUMBER&lt;FONT color=#808080&gt;()&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;OVER&lt;/FONT&gt; &lt;FONT color=#808080&gt;(&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;ORDER&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;BY&lt;/FONT&gt; ContactId &lt;FONT color=#0000ff&gt;ASC&lt;/FONT&gt; &lt;FONT color=#808080&gt;)&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; RowNumber&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; FROM&lt;/FONT&gt; @Results &lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&amp;nbsp; &lt;FONT color=#0000ff&gt;WHERE&lt;/FONT&gt; MiddleName &lt;FONT color=#808080&gt;IS&lt;/FONT&gt; &lt;FONT color=#808080&gt;NOT&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New" size=2&gt;NULL&lt;/FONT&gt; &lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;FONT color=#0000ff&gt;AS&lt;/FONT&gt; t&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE cellPadding=2 border=1&gt;

&lt;TR&gt;
&lt;TD&gt;ContactId&lt;/TD&gt;
&lt;TD&gt;FirstName&lt;/TD&gt;
&lt;TD&gt;MiddleName&lt;/TD&gt;
&lt;TD&gt;LastName&lt;/TD&gt;
&lt;TD&gt;RowNumber&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;Catherine&lt;/TD&gt;
&lt;TD&gt;R.&lt;/TD&gt;
&lt;TD&gt;Abel&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;Frances&lt;/TD&gt;
&lt;TD&gt;B.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;Margaret&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;Carla&lt;/TD&gt;
&lt;TD&gt;J.&lt;/TD&gt;
&lt;TD&gt;Adams&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;Ronald&lt;/TD&gt;
&lt;TD&gt;L.&lt;/TD&gt;
&lt;TD&gt;Adina&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;I went back and modified my queries to return more results and verified that this was indeed the solution that I was looking for. With accurate sequential ordering, I was now able to define a range using the &lt;FONT face="Courier New" size=2&gt;BETWEEN&lt;/FONT&gt; operator. I was now able to&amp;nbsp;page through&amp;nbsp;all of the instances of the Persons.Contact entity that contained a defined middle name. The complete set of SQL statements follows.&lt;/P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;USE &lt;/FONT&gt;AdventureWorks&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;DECLARE&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; @Results &lt;FONT color=#0000ff&gt;TABLE&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;BR&gt;&amp;nbsp; ContactId &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; FirstName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;FONT color=#808080&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp; MiddleName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;FONT color=#808080&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&amp;nbsp; LastName &lt;FONT color=#0000ff&gt;nvarchar&lt;/FONT&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;50&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New" size=2&gt;) &lt;/FONT&gt;&lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;INSERT&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;INTO&lt;/FONT&gt;&lt;FONT color=#000000&gt; @Results&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#000000&gt;&amp;nbsp; ContactID&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&amp;nbsp; FirstName&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&amp;nbsp; MiddleName&lt;/FONT&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;&amp;nbsp; LastName&lt;/FONT&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt;&lt;FONT color=#000000&gt; Person&lt;/FONT&gt;&lt;FONT color=#808080&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000000&gt;Contact&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;SELECT&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; &lt;FONT color=#808080&gt;*&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;FROM&lt;/FONT&gt; &lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp; SELECT&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ContactId&lt;/FONT&gt;&lt;FONT face="Courier New" color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MiddleName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROW_NUMBER&lt;FONT color=#808080&gt;()&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;OVER&lt;/FONT&gt; &lt;FONT color=#808080&gt;(&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;ORDER&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;BY&lt;/FONT&gt; ContactId &lt;FONT color=#0000ff&gt;ASC&lt;/FONT&gt; &lt;FONT color=#808080&gt;)&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;AS&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; RowNumber&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; FROM&lt;/FONT&gt; @Results &lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&amp;nbsp; &lt;FONT color=#0000ff&gt;WHERE&lt;/FONT&gt; MiddleName &lt;FONT color=#808080&gt;IS&lt;/FONT&gt; &lt;FONT color=#808080&gt;NOT&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT face="Courier New" size=2&gt;NULL&lt;/FONT&gt; &lt;BR&gt;&lt;FONT face="Courier New" size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; &lt;FONT color=#0000ff&gt;AS&lt;/FONT&gt; t&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" size=2&gt;WHERE&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; RowNumber &lt;FONT color=#808080&gt;BETWEEN&lt;/FONT&gt; 1 &lt;FONT color=#808080&gt;AND&lt;/FONT&gt; 15&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The stored procedure was updated with the code that I had come up with while testing out derived tables. Now we're able to provide a much more effective paging experience on our search page in which we are only retrieving the results that are being displayed as opposed to pulling all of the data and only displaying the appropriate partition. (OUCH).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=514429" width="1" height="1"&gt;</description></item><item><title>Passing values between two IHttpHandlers within the same HttpContext</title><link>http://blogs.msdn.com/b/csano/archive/2005/12/14/503758.aspx</link><pubDate>Thu, 15 Dec 2005 00:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:503758</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=503758</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/12/14/503758.aspx#comments</comments><description>&lt;P&gt;&lt;FONT size=2&gt;My latest ASP.NET coding endeavor required that I perform a postback and then transfer control over to a different page (primarily for URL concealment purposes) using &lt;FONT face="Courier New"&gt;Server.Transfer&lt;/FONT&gt;. I needed to be able to pass values from the source page to the target page, but didn't really have a good way to do this. A quick gander at the documentation seemed to indicate that the way to do this was to define public properties on the source page, use the &lt;FONT face="Courier New"&gt;Handler&lt;/FONT&gt; property of the &lt;FONT face="Courier New"&gt;Context&lt;/FONT&gt; instance to retrieve a &lt;FONT face="Courier New"&gt;IHttpHandler&lt;/FONT&gt;-based reference to the source page which can then be cast to the source page type, providing you with access to all of the public properties, as shown in the following code block:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#008080&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;MyPage&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; page = (&amp;nbsp;&lt;FONT color=#008080&gt;MyPage&lt;/FONT&gt; ) Context.Handler; &lt;BR&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; num = page.MyPublicProperty;&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2&gt;A MSN search (yes, really) revealed several different approaches that people have taken to persist data across multiple pages within the same HTTP context (which essentially is one round-trip to the server). One person encouraged the practice of declaring public dictionaries that are persisted in similar fashion as the code above, others&amp;nbsp;sanctioned the&amp;nbsp;use of server side (session) cookies and some&amp;nbsp;went as far as defining hidden field values and accessing them through the &lt;FONT face="Courier New"&gt;HttpValueCollection&lt;/FONT&gt; exposed by&amp;nbsp;&lt;FONT face="Courier New"&gt;HttpRequest.Form&lt;/FONT&gt; on the target page.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2&gt;I decided to take some time to go through all of the findings that I had come across and determine whether or not they would be of use. I've provided a brief summary of what I discovered as I went through each of the three different approaches that I found followed by my solution.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Declaring Public Properties&lt;/STRONG&gt; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;Declaring a public dictionary of values that I wanted to pass from the source page to the target page seemed to make sense, but I was still reluctant about exposing a public property in my &lt;FONT face="Courier New"&gt;Page&lt;/FONT&gt; class, especially when the only purpose that it would serve would be to pass this dictionary across connecting pages on the server. Additionally, this would create a strong coupling between pages that are involved in the transfer, which is something I really wanted to avoid. As an example, suppose I had three pages, A, B and C, each containing a &lt;FONT face="Courier New"&gt;Dictionary&lt;/FONT&gt; typed public property named &lt;FONT face="Courier New"&gt;Values&lt;/FONT&gt;,&amp;nbsp;that were transferred to page Z. The code would look something like this:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#008080 size=1&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Dictionary&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;FONT color=#000000&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;FONT color=#000000&gt;&amp;gt; valueDictionary;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; ( Context.Handler.GetType().Name.ToLower().Equals( "a_aspx" ) ) { &lt;BR&gt;&amp;nbsp; valueDictionary = ( ( A ) Context.Handler ).Values; &lt;BR&gt;} &lt;FONT color=#0000ff&gt;else&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; ( Context.Handler.GetType().Name.ToLower().Equals( "b_aspx" ) ) { &lt;BR&gt;&amp;nbsp; valueDictionary = ( ( B ) Context.Handler ).Values; &lt;BR&gt;} &lt;FONT color=#0000ff&gt;else&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt; ( Context.Handler.GetType().Name.ToLower().Equals( "c_aspx" ) ) { &lt;BR&gt;&amp;nbsp; valueDictionary = ( ( C ) Context.Handler ).Values; &lt;BR&gt;} &lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; { &lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp; // they shouldn't be here. redirect them somewhere else.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt; &lt;BR&gt;} &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000 size=2&gt;// do something with valueDictionary&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=1&gt;
&lt;P&gt;&lt;FONT color=#000000 size=2&gt;This kind of coupling would influence a required code change in Z if any of the following scenarios were to happen:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT size=2&gt;I decided that I wanted to transfer page D to Z. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT size=2&gt;I no longer wanted one or more of the pages to be transferred to Z. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT size=2&gt;One of the pages is no longer needed and is deleted from the web project.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Sessions&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000 size=2&gt;We have a policy that prohibits the use of sessions, so that was not something that I could use. Even if I could, I wouldn't unless it was as a last resort. Sessions, especially on a high-traffic site, can be expensive and should generally be avoided. They are also pretty much useless in&amp;nbsp;a web farm because there isn't a clean way to persist them across multiple server instances in the cluster&amp;nbsp;unless you have a centralized session server.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Hidden Form Fields&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;The &lt;FONT face="Courier New"&gt;HttpValueCollection&lt;/FONT&gt; exposed by &lt;FONT face="Courier New"&gt;HttpRequest.Form&lt;/FONT&gt; provides access to a collection&amp;nbsp;of key-value pairs in which the identities of the controls (from &lt;FONT face="Courier New"&gt;Control.ClientID&lt;/FONT&gt;)&amp;nbsp;on the source page are contained. In the case of passing data by way of hidden fields comes the requirement that you be able to retrieve a reference to the control on the server. The best way to do this is to retrieve a &lt;FONT face="Courier New"&gt;IHttpHandler&lt;/FONT&gt; based reference to the source page, casting it to the appropriate page type, invoking the &lt;FONT face="Courier New"&gt;FindControl()&lt;/FONT&gt; method on the source page instance and retrieving the control by the identifier&amp;nbsp;defined on the web form and accessing its value. This presents two distinct problems. First, by doing this, you're creating the same strong coupling dependency as you would by declaring public properties.&amp;nbsp;In addition to that,&amp;nbsp;you will have to ensure that each page that is transferred to this target page has&amp;nbsp;a control with the given ID of choice.&amp;nbsp;Secondly, you're breaking the rules of encapsulation by using &lt;FONT face="Courier New"&gt;FindControl()&lt;/FONT&gt;. This, in the eyes of many, is not recommended practice. Let's not forget&amp;nbsp;the potential performance hit that you could take by forcing a traversal of the control hierarchy.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;I was a little bit frustrated at this point. The first option seemed like the only reasonable option, but intuition pushed me towards the &lt;FONT face="Courier New"&gt;HttpContext&lt;/FONT&gt; class in the .NET Framework Class Library documentation. I figured that since I was operating within a &lt;FONT face="Courier New"&gt;HttpContext&lt;/FONT&gt; that the class might expose a collection of some sort that would allow me to define values that would persist throughout the HTTP request. I stumbled across the Items property which immediately piqued my interest. You couldn't go wrong with a description that says, "Gets a key/value collection that can be used to organize and share data between an IHttpModule&amp;nbsp;interface and an &lt;B&gt;&lt;EM&gt;IHttpHandler&lt;/EM&gt;&lt;/B&gt; interface during an HTTP request" could you? A fury of finger movement upon my keyboard resulted in the following code:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=1&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt; &lt;FONT color=#0000ff&gt;partial&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; &lt;FONT color=#008080&gt;MyPage &lt;/FONT&gt;:&amp;nbsp;&lt;FONT color=#008080&gt;Page&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; OnLoad( &lt;FONT color=#008080&gt;EventArgs&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; e ) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Context.Items[ "SomeKey" ] = 5;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Server.Transfer( "target.aspx", &lt;/FONT&gt;&lt;FONT face="Courier New" color=#0000ff&gt;true&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ); &lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;public &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;partial&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; &lt;FONT color=#008080&gt;TargetPage &lt;/FONT&gt;:&amp;nbsp;&lt;FONT color=#008080&gt;Page&lt;/FONT&gt; {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; OnLoad( &lt;FONT color=#008080&gt;EventArgs&lt;/FONT&gt; e ) {&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( Context.Items[ "SomeKey" ] == null&amp;nbsp;) {&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// redirect&lt;/FONT&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#006400&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // use value of Context.Items[ "SomeKey" ]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Mission accomplished. With this approach, the only thing that would need to be done in order to transfer a page to &lt;FONT face="Courier New"&gt;TargetPage&lt;/FONT&gt; would be to define the appropriate keys in the key/value collection exposed by &lt;FONT face="Courier New"&gt;Content.Items &lt;/FONT&gt; before initiating the transfer.&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=503758" width="1" height="1"&gt;</description></item><item><title>Windows Vista UX Guidelines</title><link>http://blogs.msdn.com/b/csano/archive/2005/09/15/467711.aspx</link><pubDate>Thu, 15 Sep 2005 19:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:467711</guid><dc:creator>csano</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=467711</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/09/15/467711.aspx#comments</comments><description>&lt;P&gt;Microsoft recently posted the preliminary &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=FD380553-911E-4659-A085-4DD58AE4B9AE&amp;amp;displaylang=en&amp;amp;Hash=Q6FRGY5"&gt;Windows Vista UX&lt;/A&gt;&amp;nbsp;guidelines.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;These guidelines contain information on What’s New in Windows Vista, design principles, guidelines for controls, text, windows, and aesthetics. They will help designers and developers create high quality, consistent Windows Vista applications.&lt;/EM&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=467711" width="1" height="1"&gt;</description></item><item><title>XAMLShare</title><link>http://blogs.msdn.com/b/csano/archive/2005/08/20/454123.aspx</link><pubDate>Sun, 21 Aug 2005 03:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:454123</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=454123</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/08/20/454123.aspx#comments</comments><description>I just came across &lt;A href="http://xamlshare.com"&gt;XAMLShare&lt;/A&gt;, a public wiki dedicated to providing various Windows Presentation Foundation (Avalon)&amp;nbsp;code samples. There aren't many samples at the time, but hopefully the number will grow as&amp;nbsp;WPF works its way into the mainstream.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=454123" width="1" height="1"&gt;</description></item><item><title>Getting away from Application.DoEvents</title><link>http://blogs.msdn.com/b/csano/archive/2005/08/14/451546.aspx</link><pubDate>Sun, 14 Aug 2005 19:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:451546</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=451546</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/08/14/451546.aspx#comments</comments><description>Another great blog entry by Jessica Fosler: &lt;a href="http://blogs.msdn.com/jfoscoding/archive/2005/08/06/448560.aspx"&gt;Keeping your UI Responsive and the Dangers of Application.DoEvents&lt;/A&gt;.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=451546" width="1" height="1"&gt;</description></item><item><title>Wrapping text in DataGrid cells</title><link>http://blogs.msdn.com/b/csano/archive/2005/07/14/438738.aspx</link><pubDate>Thu, 14 Jul 2005 13:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:438738</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=438738</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/07/14/438738.aspx#comments</comments><description>&lt;P&gt;One of the most common questions I've been asked in recent weeks has been in regards to creating a data grid column style that supports text wrapping. It's really unfortunate that the DataGrid control does not provide this type of functionality, and even more that achieving&amp;nbsp;a such effect is such a daunting task that requires a thorough comprehension of the control's rendering&amp;nbsp;infrastructure. Since this was a requirement for one of the tools that I'm currently working on, I had no choice but to sit down and endure some pain&amp;nbsp;in attempting to make this happen. I just finished up a very rough slab of &lt;A href="http://sano.dotnetgeeks.net/code/dataGridColumnWrap.zip"&gt;code&lt;/A&gt;&amp;nbsp;that produces what is visible in the following screenshot:&lt;/P&gt;
&lt;P&gt;&lt;IMG height=360 src="http://sano.dotnetgeeks.net/images/dataGridColumnWrapShot.jpg" width=480&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before you make a mad&amp;nbsp;rush to download, please be cognizant that this is code in its crudest form. I'll update the&amp;nbsp;sample as the tool proceeds through its stabilization phase. In the meantime, feel free to get in touch with me if there are any questions. Enjoy.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=438738" width="1" height="1"&gt;</description></item><item><title>ColorPicker.NET v0.1.1</title><link>http://blogs.msdn.com/b/csano/archive/2005/07/13/438637.aspx</link><pubDate>Thu, 14 Jul 2005 03:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:438637</guid><dc:creator>csano</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/csano/rsscomments.aspx?WeblogPostID=438637</wfw:commentRss><comments>http://blogs.msdn.com/b/csano/archive/2005/07/13/438637.aspx#comments</comments><description>&lt;P&gt;I had a few cycles today so I spent some time fixing some bugs in &lt;A href="http://sano.dotnetgeeks.net/colorpicker"&gt;ColorPicker.NET&lt;/A&gt;.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=438637" width="1" height="1"&gt;</description></item></channel></rss>