setting entire row as a hyperlink

  • Thread starter Adam The Generic
  • Start date
A

Adam The Generic

Hi All,

in a gridview , we can set some fields as a hyperlink and it works if user
clicks that specific cell .
for example ..
//*******
<Columns>
<asp:TemplateField HeaderText="Product Name" >
<ItemTemplate>
<asp:HyperLink ID="Label1" Runat="Server"
NavigateUrl='<%#"~/ProductDetails.aspx?ProductCode="+ Eval("STOCK_CODE")%>'
Text='<%# Eval("STOCK_NAME") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="QUANTITY" HeaderText="Quantity" />
<asp:BoundField DataField="FIRM" HeaderText="Made By" />
</Columns>
//********

is it possible to set entire row as a hyperlink ?

Thanks in advance.
 
Joined
May 16, 2006
Messages
27
Reaction score
0
In the RowDataBound of the Grid,

If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onclick") = "window.location.href = '" + Request.ApplicationPath + "/ProductDetails.aspx?ProductCode=" + Eval("STOCK_CODE").ToString() + "';"
e.Row.Attributes("onmouseover") = "this.style.cursor='hand';"
e.Row.Attributes("onmouseout") = "this.style.cursor='default';"
End If

If you want, you can apply the style on mouseover of the row.
like,
"this.style.cursor='hand';this.className = 'highlight';"
same with mouseout,
"this.style.cursor='default';this.className = 'normal';"
 

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,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top