Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

changing the forecolor of a hyperlink of a datagrid

Posted on 2004-10-08
5
Medium Priority
?
461 Views
Last Modified: 2010-05-18
Hi,

I have created a hyperlink using a template column on a datagrid ...
<asp:TemplateColumn HeaderText="Report">
            <ItemTemplate>
                  <asp:Hyperlink runat="server" Text='View Details' ForeColor="Purple" NavigateUrl='<%# "page.aspx?ViewID=" & Server.UrlEncode(Container.DataItem("datafield"))%>' ID="Hyperlink1"/>
                                                                  </ItemTemplate>
                                                            </asp:TemplateColumn>

Now..everything works fine..when i click on the hyperlink, it takes me to a new page..

what i want to do is when the user moves his mouse over the hyperlink, the forecolor of the hyperlink should change...i tried the following but it didnt work..
'If e.Item.ItemType = ListItemType.AlternatingItem Then
           e.Item.Cells(7).Attributes.Add("onmouseover", "this.style.color='#FF0000'")
           e.Item.Cells(7).Attributes.Add("onmouseout", "this.style.color='Purple'")
           End If

i tried this.style.ForeColor also..it didnt work..what i found out was, this was overridden by the forecolor attritbute that was set while displaying the hyperlink itself...
if so how would i implement the following??

Thanks,
Pra4444
0
Comment
Question by:Pra4444
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
praneetha earned 300 total points
ID: 12259585
If e.Item.ItemType <> ListItemType.Header && e.Item.ITemType<>ListItem.Footer Then
HyperLink tesh=(HyperLink) e.Item.Cells(7).FindControl("HyperLink1");//type cast this to Hyperlink in vb.net this is C#
           testh.Attributes.Add("onmouseover", "this.style.color='#FF0000'")
            tesh.Attributes.Add("onmouseout", "this.style.color='Purple'")
           End If

try that
0
 
LVL 12

Author Comment

by:Pra4444
ID: 12259649
Hi,

On what event would i write that too??

example::: Item_Created, or Item_DataBound??


Thanks,
Pra4444
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12259671
Where do you have this code? It should be inside ItemDataBound Event:

If e.Item.ItemType = ListItemType.AlternatingItem Then
          ( (HyperLink) e.Item.Cells(7).controls(0) ).Attributes.Add("onmouseover", "this.style.color='#FF0000'")
           ( (HyperLink) e.Item.Cells(7).controls(0) ).Attributes.Add("onmouseout", "this.style.color='Purple'")
End If

-tushar
0
 
LVL 12

Author Comment

by:Pra4444
ID: 12259714
it works perfectly..thanks...

Pra4444
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12259718
yesh it shoul dbe inside ItemDataBound
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question