MikeMCSD
asked on
Making the whole cell a Hyperlink when mouse is moved over it
I want to make this whole cell (column) a hyperlink, so when the mouse is moved over it,
the cell back color changes, and you can click any where in the cell to go to the link.
<asp:TemplateField ItemStyle-Width="35%">
<ItemTemplate>
<a href="ProductDetails.aspx? ProductId= <%#Eval("P roductId") %>" style="font-size:14px;">
<%#Server.HtmlEncode(Eval( "Name").To String())% >
</a>
</ItemTemplate></asp:Templ ateField>
How can I do this? thanks
the cell back color changes, and you can click any where in the cell to go to the link.
<asp:TemplateField ItemStyle-Width="35%">
<ItemTemplate>
<a href="ProductDetails.aspx?
<%#Server.HtmlEncode(Eval(
</a>
</ItemTemplate></asp:Templ
How can I do this? thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Can you do it like follows?
<a href="ProductDetails.aspx?ProductId=<%#Eval("ProductId")%>" class="wholeCell" >
<asp:TemplateField ItemStyle-Width="35%">
<ItemTemplate>
<%#Server.HtmlEncode(Eval("Name").ToString())%>
</ItemTemplate></asp:TemplateField>
</a>
ASKER
was thinking of trying that but figured the compiler wouldn't like that, and it didn't.
I'm guessing this is not possible to do with these templates in the grid view.
Just have to keep experimenting I guess.
I'm guessing this is not possible to do with these templates in the grid view.
Just have to keep experimenting I guess.
Try this:
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
For Each row As GridViewRow In GridView1.Rows
row.Cells(1).Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='none';"
Next
End Sub
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
When I tried that, it only made the text of the cell change its back color, not the whole cell.
I tried this :
<asp:TemplateField ItemStyle-Width="35%" ItemStyle-CssClass="wholeCell">
<ItemTemplate>
<a href="ProductDetails.aspx?
...
When I move the mouse over, the whole cell changes back color, but only the text has a clickable link.
Being this is a ASP.NET <asp:GridView>, it's hard to do these kind of things because you don't know what the
gridview is doing behind the scenes. Just have to experiment I guess.