Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am phasing issue with grid view,I am trying to send one href link with one onclick = function() to the gridview.That is not working because HTML code displaying as it is in gridview instead of showing hyper link.

I want to call javascript function through this hyper link.

So please if any one have any solution than reply.

Thanks and regards,
vinod
Posted
Comments
Zafar Sultan 12-Jun-13 8:29am    
Can you post your code?

1 solution

You can do like below.

Html Anchor

Refer - http://stackoverflow.com/a/2942811[^].
Quote:
The solution I found was using asp:TemplateField this way, without losing the Sorting ability and using the datatextfield using Eval:
ASP.NET
<asp:TemplateField HeaderText="Name" SortExpression="PartnerName">
    <ItemTemplate>
        <a onclick="javascript:alert('ok')" href="http://<%#Eval("PartnerName")%>"><%#Eval("PartnerName")%></a>
    </ItemTemplate>
</asp:TemplateField>

Asp HyperLink

Refer - Passing gridview variables to javascript popup through "onclick"[^].
Quote:
I test it and this following one works for me:

ASP.NET
<asp:TemplateField>
     <ItemTemplate>
          <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl=<%# String.Format("javascript:void(window.open('http://www.{0}.com'))", Eval("ProductID")) %>> HyperLink</asp:HyperLink>
      </ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900