title: ASP.NET 4 ACCESS DATA TO APPLY TO NavigateUrl
body: <p>I am currently learning .net and have come to a brick wall with trying to implement url rounting.</p>
  
  <p>I have most of it working fine, but I am trying to generate hyperlinks from information in my database.</p>
  
  <p>I am getting the data out fine using:</p>
  
  <pre><code>    'portfolio navigation data
      Dim rdrPortfolioNav As SqlDataReader
  
      Dim cmdPortfolioNav As SqlCommand = New SqlCommand()
      cmdPortfolioNav.CommandText = "SELECT TOP 6 [id], [date], [client], [category], [title], [body], [website], [navimage], [navdesc] FROM [portfolio] ORDER BY [date] DESC"
      cmdPortfolioNav.CommandType = CommandType.Text
      cmdPortfolioNav.Connection = boomSQL
  
      cmdPortfolioNav.Connection.Open()
      rdrPortfolioNav = cmdPortfolioNav.ExecuteReader(CommandBehavior.CloseConnection)
  
      lvPortfolioNav.DataSource = rdrPortfolioNav
      lvPortfolioNav.DataBind()
  
      cmdPortfolioNav.Dispose()
  </code></pre>
  
  <p>On the front end i can access the data and show all records using:</p>
  
  <pre><code>&lt;asp:ListView ID="lvPortfolioNav" runat="server"&gt;
  &lt;ItemTemplate&gt;
      &lt;div class="work"&gt;
          &lt;asp:HyperLink runat="server" NavigateUrl="portfolio/&lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;id&amp;quot;)%&gt;/&lt;%# FormatLinks(DataBinder.Eval(Container.DataItem, &amp;quot;category&amp;quot;)) %&gt;/&lt;%# FormatLinks(DataBinder.Eval(Container.DataItem, &amp;quot;title&amp;quot;)) %&gt;" ToolTip=""&gt;&lt;span class="title"&gt;&lt;%# DataBinder.Eval(Container.DataItem, "title")%&gt;&lt;/span&gt;&lt;/asp:HyperLink&gt;
          &lt;asp:Image runat="server" ImageUrl="&lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;navimage&amp;quot;)%&gt;" AlternateText="&lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;client&amp;quot;)%&gt;" ToolTip="&lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;client&amp;quot;)%&gt;" /&gt;
          &lt;span class="desc"&gt;&lt;%# DataBinder.Eval(Container.DataItem, "navdesc")%&gt;&lt;/span&gt; &lt;/div&gt;
  &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>The problem is this line:</p>
  
  <pre><code>&lt;asp:HyperLink runat="server" NavigateUrl="portfolio/&lt;%# DataBinder.Eval(Container.DataItem, &amp;quot;id&amp;quot;)%&gt;/&lt;%# FormatLinks(DataBinder.Eval(Container.DataItem, &amp;quot;category&amp;quot;)) %&gt;/&lt;%# FormatLinks(DataBinder.Eval(Container.DataItem, &amp;quot;title&amp;quot;)) %&gt;" ToolTip=""&gt;&lt;span class="title"&gt;&lt;%# DataBinder.Eval(Container.DataItem, "title")%&gt;&lt;/span&gt;&lt;/asp:HyperLink&gt;
  </code></pre>
  
  <p>it won't get the values from the database and in the html the link literally comes out as:</p>
  
  <pre><code>&lt;a href="../../portfolio/%3C%25#%20DataBinder.Eval(Container.DataItem,%20%22id%22)%25%3E/%3C%25%23%20FormatLinks(DataBinder.Eval(Container.DataItem,%20%22category%22))%20%25%3E/%3C%25%23%20FormatLinks(DataBinder.Eval(Container.DataItem,%20%22title%22))%20%25%3E"&gt;&lt;span class="title"&gt;Kingston Bagpuize House Website&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  
  <p>the same thing works fine for the ImageUrl so not sure what i'm doing wrong.</p>
  
  <p>I know you can do something in the backend code to generate the urls but i can't for the life of me find anything on the internet.....help would be very much appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>J.</p>