Dynamic Hyperlink Navigate Url

  • Thread starter Ganesh Krishnamurthy
  • Start date
G

Ganesh Krishnamurthy

Hi,
I got a DataList control (the reason for using datalist is i need
columnlayout), using ItemTemplate add Hyperlink control i need the link to
be dynamic ..

<asp:HyperLink id=HyperLink1 runat="server" Text="<%# Container.DataItem(2)
%>" NavigateUrl="product.asp?sku=<%# Container.DataItem(1)%>&amp;dept_id=<%#
Container.DataItem(3)%>">

</asp:HyperLink>

When i issue the above command it doesnt work i get the actual textprinted
there eg:-
http://localhost/WebApplication1/product.asp?sku=<%#
Container.DataItem(1)%>&dept_id=<% Container.DataItem(3)%>

Where as i need it to look like this
http://localhost/WebApplication1/product_detail.asp?sku=1450&dept_id=20

I cannot use a variable since it will be multiple ..

Thx
 
C

CMA

this sample code in C#, u have to change to VB.NET

in the navigate url place put.. <%# getURL(Container.DataItem(1),
Container.DataItem(3)) %>

in the page header put the server side script..

<script language=c# runat=server>
public string getURL(object strOne, object strTwo)
{
string lstrURL = "product.asp?sku="+ strOne.ToString() +"&dept_id="+
strTwo.ToString();
return lstrURL;
}
</script>

hope this helps,
CMA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top