title: Rendering line breaks in HTML from SQL datasource
body: <p>I am returning multiple rows of a column as one single row and column:</p>
  
  <pre><code>SELECT STUFF((
                  SELECT '&lt;br/&gt;' + Notes 
                  FROM DailyTaskHours
                  WHERE Notes IS NOT NULL
                      AND Notes &lt;&gt; ''
                      AND NonScrumStoryId = DTH.NonScrumStoryId
                  FOR XML PATH('')
                  ), 1, 1, '')
                  )
  </code></pre>
  
  <p>I want to insert line breaks between each row that is being concatenated in ASP.NET but my approach is not working:</p>
  
  <p><img src="https://i.stack.imgur.com/gX99r.png" alt="enter image description here"></p>
  
  <p>As you can see <br/> is being replaced by the database engine with <code>&amp;lt;br /&amp;gt;</code> How do I get the linebreaks in the database so it will render spaced on the webpage?</p>
  
  <p>Here is the entire control that I am working on for reference:</p>
  
  <pre><code>        &lt;asp:GridView CssClass="hoursGrid" ID="hoursReportGridView" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84"
              BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource2" OnRowDataBound="hoursReportGridView_OnRowDataBound" DataKeyNames="DifferentUsers, DoubleBookedFlag, PointPerson, Person"&gt;
              &lt;Columns&gt;
                  &lt;asp:BoundField DataField="Person" HeaderText="Person" SortExpression="Project" /&gt;
                  &lt;asp:BoundField DataField="Project" HeaderText="Project" SortExpression="Project" /&gt;
                  &lt;asp:BoundField DataField="ProjectType" HeaderText="Project Type" ReadOnly="True" SortExpression="Sprint" ItemStyle-HorizontalAlign="Center" /&gt;
                  &lt;asp:BoundField DataField="Theme" HeaderText="Theme" ReadOnly="True" SortExpression="Theme" ItemStyle-HorizontalAlign="Center" /&gt;
                  &lt;asp:BoundField DataField="StoryNumber" HeaderText="Story Number" SortExpression="Story" ItemStyle-Width="6%" ItemStyle-HorizontalAlign="Center" /&gt;
                  &lt;asp:BoundField DataField="StoryTitle" HeaderText="Story Title" SortExpression="Story" ItemStyle-Width="20%" /&gt;
                  &lt;asp:BoundField DataField="Effort" HeaderText="Effort" SortExpression="Effort" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Task" HeaderText="Task" SortExpression="Task"  ItemStyle-Width="20%" /&gt;
                  &lt;asp:BoundField DataField="OriginalEstimateHours" HeaderText="Original Estimate" SortExpression="OriginalEstimateHours" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Monday" HeaderText="Mon" ReadOnly="True" SortExpression="Monday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Tuesday" HeaderText="Tues" ReadOnly="True" SortExpression="Tuesday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Wednesday" HeaderText="Wed" ReadOnly="True" SortExpression="Wednesday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Thursday" HeaderText="Thurs" ReadOnly="True" SortExpression="Thursday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Friday" HeaderText="Fri" ReadOnly="True" SortExpression="Friday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Saturday" HeaderText="Sat" ReadOnly="True" SortExpression="Saturday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="Sunday" HeaderText="Sun" ReadOnly="True" SortExpression="Sunday" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right"&gt;
                  &lt;ItemTemplate&gt;
                       &lt;asp:LinkButton ID="taskLinkButton" Text='&lt;%# Eval("Total") %&gt;' Enabled='&lt;%# Eval("StoryTitle").ToString() != "" %&gt;' runat="server" OnClick="taskLinkButton_Click" /&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
              &lt;FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /&gt;
              &lt;HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /&gt;
              &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
              &lt;RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /&gt;
              &lt;SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /&gt;
              &lt;SortedAscendingCellStyle BackColor="#FFF1D4" /&gt;
              &lt;SortedAscendingHeaderStyle BackColor="#B95C30" /&gt;
              &lt;SortedDescendingCellStyle BackColor="#F1E5CE" /&gt;
              &lt;SortedDescendingHeaderStyle BackColor="#93451F" /&gt;
          &lt;/asp:GridView&gt;
          &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ApplicationServices %&gt;" 
              SelectCommand="
  SELECT RowType AS RowType
      ,Person AS Person
      ,Project AS Project
      ,ProjectType AS ProjectType
      ,Theme AS Theme
      ,StoryNumber AS StoryNumber
      ,StoryTitle AS StoryTitle
      ,Effort AS Effort
      ,Task AS Task
      ,OriginalEstimateHours AS OriginalEstimateHours
      ,MondayHours AS Monday
      ,TuesdayHours AS Tuesday
      ,WednesdayHours AS Wednesday
      ,ThursdayHours AS Thursday
      ,FridayHours AS Friday
      ,SaturdayHours AS Saturday
      ,SundayHours AS Sunday
      ,TotalHours AS Total
      ,DifferentUsers AS DifferentUsers
      ,DoubleBookedFlag AS DoubleBookedFlag
      ,PointPerson AS PointPerson
  FROM (
      -- DATE DISPLAY
      SELECT '1' AS RowType
          ,'' AS Person
          ,'' AS Project
          ,'Category' AS ProjectType
          ,'' AS Theme
          ,'Ticket #' AS StoryNumber
          ,'' AS StoryTitle
          ,'' AS Effort
          ,'' AS Task
          ,'' AS OriginalEstimateHours
          ,'' AS Category
          ,'' AS IncidentNumber
          ,'' AS ApplicationName
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 0, @startDateParam)) = 2
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 0, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS MondayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 1, @startDateParam)) = 3
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 1, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS TuesdayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 2, @startDateParam)) = 4
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 2, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS WednesdayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 3, @startDateParam)) = 5
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 3, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS ThursdayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 4, @startDateParam)) = 6
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 4, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS FridayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 5, @startDateParam)) = 7
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 5, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS SaturdayHours
          ,(
              CASE 
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &gt;= 7
                      THEN ''
                  WHEN DATEDIFF(d, @startDateParam, @endDateParam) &lt;= 5
                      THEN ''
                  WHEN DATEPART(dw, DATEADD(DAY, 6, @startDateParam)) = 1
                      THEN CONVERT(VARCHAR(5), DATEADD(DAY, 6, @startDateParam), 101)
                  ELSE ''
                  END
              ) AS SundayHours
          ,'' AS TotalHours
          ,'' AS DifferentUsers
          ,'' AS DoubleBookedFlag
          ,'' AS PointPerson
      --
  
      UNION ALL
  
      --
      -- GRAND TOTALS
      --
      SELECT '2' AS RowType
          ,'All Personnel' AS Person
          ,'' AS Project
          ,'' AS ProjectType
          ,'' AS Theme
          ,'' AS StoryNumber
          ,'' AS StoryTitle
          ,'' AS Effort
          ,'Total:' AS Task
          ,'' AS OriginalEstimateHours
          ,'' AS Category
          ,'' AS IncidentNumber
          ,'' AS ApplicationName
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 2
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Monday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 3
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Tuesday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 4
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Wednesday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 5
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Thursday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 6
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Friday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 7
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Saturday
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 1
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS Sunday
          ,CAST(SUM(DTH.[Hours]) AS VARCHAR(20)) AS Total
          ,'' AS DifferentUsers
          ,'' AS DoubleBookedFlag
          ,'' AS PointPerson
      FROM DailyTaskHours DTH
      LEFT JOIN NonScrumStory NSS ON DTH.NonScrumStoryId = NSS.PK_NonScrumStory
      LEFT JOIN Task TSK ON DTH.TaskId = TSK.PK_Task
      LEFT JOIN Story STY ON TSK.StoryId = STY.PK_Story
      LEFT JOIN Product PDT ON STY.ProductId = PDT.PK_Product
      LEFT JOIN [User] USR ON DTH.EnteredBy = USR.DisplayName
      WHERE DTH.EnteredBy LIKE @userParam
          AND ActivityDate &gt;= @startDateParam
          AND ActivityDate &lt;= @endDateParam
          AND 1 = CASE ISNUMERIC(@productId)
              WHEN 0
                  THEN CASE 
                          WHEN DTH.TaskId IS NULL
                              OR PDT.PK_Product LIKE @productId
                              THEN 1
                          END
              WHEN 1
                  THEN CASE 
                          WHEN DTH.TaskId IS NOT NULL
                              AND PDT.PK_Product = @productId
                              THEN 1
                          END
              END
          AND (
              (
                  @orgTeamPK = '%'
                  AND (
                      USR.[OrganizationalTeamId] LIKE @orgTeamPK
                      OR USR.[OrganizationalTeamId] IS NULL
                      )
                  )
              OR (
                  @orgTeamPK &lt;&gt; '%'
                  AND (USR.[OrganizationalTeamId] LIKE @orgTeamPK)
                  )
              )
          AND (
              (
                  STY.Number LIKE @search
                  OR STY.Number IS NULL
                  )
              OR (
                  STY.Title LIKE @search
                  OR STY.Title IS NULL
                  )
              OR (
                  TSK.NAME LIKE @search
                  OR TSK.NAME IS NULL
                  )
              )
          AND (
              (
                  @theme = '%'
                  AND (
                      dbo.primaryTheme(STY.[Number]) LIKE @theme
                      OR dbo.primaryTheme(STY.[Number]) IS NULL
                      )
                  )
              OR (
                  @theme != '%'
                  AND dbo.primaryTheme(STY.[Number]) = @theme
                  )
              )
  
      UNION ALL
  
      --
      -- Details by PERSON, PROJECT, SPRINT, STORY, TASK
      --
      SELECT '3' AS RowType
          ,DTH.EnteredBy AS Person
          ,COALESCE(PDT.[Name], APP.AppName) AS Project
          ,(
              CASE 
                  WHEN (
                          STY.KanBanProductId IS NOT NULL
                          AND STY.SprintId IS NULL
                          )
                      THEN 'Kanban'
                  WHEN (
                          STY.KanBanProductId IS NULL
                          AND STY.SprintId IS NOT NULL
                          )
                      THEN 'Sprint'
                  ELSE SCY.Catagory
                  END
              ) AS ProjectType
          ,dbo.primaryTheme(STY.[Number]) AS Theme
          ,COALESCE(STY.[Number], NSS.IncidentNumber) AS StoryNumber
          ,COALESCE(STY.Title, NSS.[Description]) AS StoryTitle
          ,CONVERT(VARCHAR(20), STY.Effort) AS Effort
          ,COALESCE(TSK.[Name], (
                  SELECT STUFF((
                              SELECT ' | ' + Notes 
                              FROM DailyTaskHours
                              WHERE Notes IS NOT NULL
                                  AND Notes &lt;&gt; ''
                                  AND NonScrumStoryId = DTH.NonScrumStoryId
                              FOR XML PATH('')
                              ), 1, 1, '')
                  )) AS Task
          ,CONVERT(VARCHAR(20), TSK.OriginalEstimateHours) AS OriginalEstimateHours
          ,SCY.Catagory AS Category
          ,NSS.IncidentNumber AS IncidentNumber
          ,APP.AppName AS ApplicationName
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 2
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS MondayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 3
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS TuesdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 4
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS WednesdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 5
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS ThursdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 6
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS FridayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 7
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS SaturdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 1
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS SundayHours
          ,CAST(SUM(DTH.[Hours]) AS VARCHAR(20)) AS TotalHours
          ,CAST(SUM(CASE 
                      WHEN DTH.Hours &gt; 0
                          THEN DTH.[UserDifference]
                      END) AS VARCHAR(20)) AS DifferentUsers
          ,CAST(SUM(CASE 
                      WHEN DTH.Hours &gt; 0
                          THEN DTH.DoubleBookedFlag
                      END) AS VARCHAR(20)) AS DoubleBookedFlag
          ,DTH.PointPerson AS PointPerson
      FROM DailyTaskHours DTH
      LEFT JOIN Task TSK ON DTH.TaskId = TSK.PK_Task
      LEFT JOIN Story STY ON TSK.StoryId = STY.PK_Story
      LEFT JOIN NonScrumStory NSS ON DTH.NonScrumStoryId = NSS.PK_NonScrumStory
      LEFT JOIN SupportCatagory SCY ON NSS.CatagoryId = SCY.PK_SupportCatagory
      LEFT JOIN [Application] APP ON NSS.ApplicationId = APP.PK_Application
      LEFT JOIN Sprint SPT ON STY.SprintId = SPT.PK_Sprint
      LEFT JOIN Product PDT ON STY.ProductId = PDT.PK_Product
      LEFT JOIN [User] USR ON DTH.EnteredBy = USR.DisplayName
      WHERE DTH.EnteredBy LIKE @userParam
          AND ActivityDate &gt;= @startDateParam
          AND ActivityDate &lt;= @endDateParam
          AND 1 = CASE ISNUMERIC(@productId)
              WHEN 0
                  THEN CASE 
                          WHEN DTH.TaskId IS NULL
                              OR PDT.PK_Product LIKE @productId
                              THEN 1
                          END
              WHEN 1
                  THEN CASE 
                          WHEN DTH.TaskId IS NOT NULL
                              AND PDT.PK_Product = @productId
                              THEN 1
                          END
              END
          AND (
              (
                  @orgTeamPK = '%'
                  AND (
                      USR.[OrganizationalTeamId] LIKE @orgTeamPK
                      OR USR.[OrganizationalTeamId] IS NULL
                      )
                  )
              OR (
                  @orgTeamPK &lt;&gt; '%'
                  AND (USR.[OrganizationalTeamId] LIKE @orgTeamPK)
                  )
              )
          AND (
              (
                  STY.Number LIKE @search
                  OR STY.Number IS NULL
                  )
              OR (
                  STY.Title LIKE @search
                  OR STY.Title IS NULL
                  )
              OR (
                  TSK.NAME LIKE @search
                  OR TSK.NAME IS NULL
                  )
              )
          AND (
              (
                  @theme = '%'
                  AND (
                      dbo.primaryTheme(STY.[Number]) LIKE @theme
                      OR dbo.primaryTheme(STY.[Number]) IS NULL
                      )
                  )
              OR (
                  @theme != '%'
                  AND dbo.primaryTheme(STY.[Number]) = @theme
                  )
              )
      GROUP BY DTH.EnteredBy
          ,PDT.[Name]
          ,SPT.[Name]
          ,SPT.[Description]
          ,STY.[Number]
          ,STY.Title
          ,TSK.[Name]
          ,SCY.Catagory
          ,NSS.IncidentNumber
          ,APP.AppName
          ,STY.KanBanProductId
          ,STY.SprintId
          ,NSS.[Description]
          ,TSK.OriginalEstimateHours
          ,STY.Effort
          ,DTH.PointPerson
          ,DTH.NonScrumStoryId
      HAVING SUM(DTH.[Hours]) &gt; 0
      --
  
      UNION ALL
  
      --
      -- Sub-TOTAL by PERSON
      --
      SELECT '4' AS RowType
          ,DTH.EnteredBy AS Person
          ,'' AS Project
          ,'' AS ProjectType
          ,'' AS Theme
          ,'' AS StoryNumber
          ,'' AS StoryTitle
          ,'' AS Effort
          ,'Subtotal:' AS Task
          ,'' AS OriginalEstimateHours
          ,'' AS Category
          ,'' AS IncidentNumber
          ,'' AS ApplicationName
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 2
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS MondayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 3
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS TuesdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 4
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS WednesdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 5
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS ThursdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 6
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS FridayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 7
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS SaturdayHours
          ,CAST(SUM(CASE 
                      WHEN DATEPART(dw, DTH.ActivityDate) = 1
                          THEN DTH.[Hours]
                      ELSE 0
                      END) AS VARCHAR(20)) AS SundayHours
          ,CAST(SUM(DTH.[Hours]) AS VARCHAR(20)) AS TotalHours
          ,'' AS DifferentUsers
          ,'' AS DoubleBookedFlag
          ,'' AS PointPerson
      FROM DailyTaskHours DTH
      LEFT JOIN Task TSK ON DTH.TaskId = TSK.PK_Task
      LEFT JOIN Story STY ON TSK.StoryId = STY.PK_Story
      LEFT JOIN Product PDT ON STY.ProductId = PDT.PK_Product
      LEFT JOIN [User] USR ON DTH.EnteredBy = USR.DisplayName
      WHERE DTH.EnteredBy LIKE @userParam
          AND ActivityDate &gt;= @startDateParam
          AND ActivityDate &lt;= @endDateParam
          AND 1 = CASE ISNUMERIC(@productId)
              WHEN 0
                  THEN CASE 
                          WHEN DTH.TaskId IS NULL
                              OR PDT.PK_Product LIKE @productId
                              THEN 1
                          END
              WHEN 1
                  THEN CASE 
                          WHEN DTH.TaskId IS NOT NULL
                              AND PDT.PK_Product = @productId
                              THEN 1
                          END
              END
          AND (
              (
                  @orgTeamPK = '%'
                  AND (
                      USR.[OrganizationalTeamId] LIKE @orgTeamPK
                      OR USR.[OrganizationalTeamId] IS NULL
                      )
                  )
              OR (
                  @orgTeamPK &lt;&gt; '%'
                  AND (USR.[OrganizationalTeamId] LIKE @orgTeamPK)
                  )
              )
          AND (
              (
                  STY.Number LIKE @search
                  OR STY.Number IS NULL
                  )
              OR (
                  STY.Title LIKE @search
                  OR STY.Title IS NULL
                  )
              OR (
                  TSK.NAME LIKE @search
                  OR TSK.NAME IS NULL
                  )
              )
          AND (
              (
                  @theme = '%'
                  AND (
                      dbo.primaryTheme(STY.[Number]) LIKE @theme
                      OR dbo.primaryTheme(STY.[Number]) IS NULL
                      )
                  )
              OR (
                  @theme != '%'
                  AND dbo.primaryTheme(STY.[Number]) = @theme
                  )
              )
      GROUP BY DTH.EnteredBy
      HAVING SUM(DTH.[Hours]) &gt; 0
      ) AS My_View
  ORDER BY Person
      ,RowType
      ,Project
      ,ProjectType
      ,StoryNumber
      ,StoryTitle
      ,Task
              "&gt;
              &lt;SelectParameters&gt;
                  &lt;asp:QueryStringParameter Name="userParam" Type="String" DefaultValue="%" /&gt;
                  &lt;asp:QueryStringParameter Name="startDateParam" Type="String" /&gt;
                  &lt;asp:QueryStringParameter Name="endDateParam" Type="String" /&gt;
                  &lt;asp:QueryStringParameter Name="orgTeamPK" Type="String" DefaultValue="%" /&gt;
                  &lt;asp:QueryStringParameter Name="productId" Type="String" DefaultValue="%" /&gt;
                  &lt;asp:QueryStringParameter Name="search" Type="String" DefaultValue="%" /&gt;
                  &lt;asp:QueryStringParameter Name="theme" Type="String" /&gt;
              &lt;/SelectParameters&gt;
          &lt;/asp:SqlDataSource&gt;
  </code></pre>