Tutorial - How to make the Product Name a Hyperlink for the whole column

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Can see it here : http://i185.photobucket.com/albums/x307/GaryNull/cellHighlight.gif

The whole highlighted column is a hyperlink and is clickable, not just the text part.

In the file : \Administration\Modules\Products.ascx,

Add the <div> and <a> tags here (or just copy this whole thing) :

<asp:GridView ID="gvProducts ..................

<asp:TemplateField HeaderText="<% $NopResources:Admin.Products.Name %>" ItemStyle-Width="35%">
<ItemTemplate>
<div class="navbar">
<a href="ProductDetails.aspx?ProductId=<%#Eval("ProductId")%>">
<asp:Image runat="server" ID="imgProduct" Visible="false" style="margin-right:10px;" />
<%#Server.HtmlEncode(Eval("Name").ToString())%>
</a></div>
</ItemTemplate></asp:TemplateField>

Then add this to : \App_Themes\administration\styles.css

div.navbar {border-collapse: collapse; width:100%;}
div.navbar a{display: block; width: 100%; padding: 5px; text-decoration:none; font-size:14px;}
div.navbar a:link, a:visited {color: #333;}
div.navbar a:hover, a:active {color: #000; background-color: #D3D3D3; text-decoration:none;}

Can do it for the Category page too :  \Administration\Modules\Categories.ascx

<asp:GridView ID="gvCategories" ..........................
<Columns>

<asp:TemplateField HeaderText="<% $NopResources:Admin.Categories.Name %>" ItemStyle-Width="55%">
<ItemTemplate>
<div class="navbar">
<a href="CategoryDetails.aspx?CategoryId=<%#Eval("CategoryId")%>">
<%# Server.HtmlEncode(GetCategoryFullName((Category)Container.DataItem))%>
<asp:HiddenField ID="hfCategoryId" runat="server" Value='<%# Eval("CategoryId") %>' />
</a></div>
</ItemTemplate></asp:TemplateField>
13 years ago
-
12 years ago
Thank you so much! I was looking for this piece of code!

Keep us updated when you got some more tricks. please.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.