I am currently learning .net and have come to a brick wall with trying to implement url rounting.
I have most of it working fine, but I am trying to generate hyperlinks from information in my database.
I am getting the data out fine using:
'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()
On the front end i can access the data and show all records using:
<asp:ListView ID="lvPortfolioNav" runat="server">
<ItemTemplate>
<div class="work">
<asp:HyperLink runat="server" NavigateUrl="portfolio/<%# DataBinder.Eval(Container.DataItem, "id")%>/<%# FormatLinks(DataBinder.Eval(Container.DataItem, "category")) %>/<%# FormatLinks(DataBinder.Eval(Container.DataItem, "title")) %>" ToolTip=""><span class="title"><%# DataBinder.Eval(Container.DataItem, "title")%></span></asp:HyperLink>
<asp:Image runat="server" ImageUrl="<%# DataBinder.Eval(Container.DataItem, "navimage")%>" AlternateText="<%# DataBinder.Eval(Container.DataItem, "client")%>" ToolTip="<%# DataBinder.Eval(Container.DataItem, "client")%>" />
<span class="desc"><%# DataBinder.Eval(Container.DataItem, "navdesc")%></span> </div>
</ItemTemplate>
The problem is this line:
<asp:HyperLink runat="server" NavigateUrl="portfolio/<%# DataBinder.Eval(Container.DataItem, "id")%>/<%# FormatLinks(DataBinder.Eval(Container.DataItem, "category")) %>/<%# FormatLinks(DataBinder.Eval(Container.DataItem, "title")) %>" ToolTip=""><span class="title"><%# DataBinder.Eval(Container.DataItem, "title")%></span></asp:HyperLink>
it won't get the values from the database and in the html the link literally comes out as:
<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"><span class="title">Kingston Bagpuize House Website</span></a>
the same thing works fine for the ImageUrl so not sure what i'm doing wrong.
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.
Thanks.
J.