Click here to Skip to main content
16,019,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have dynamic gridview,On gridview row cells[3] I have hyperink button ..
On mouse over of hyper link button I need to display image.
this is my code.


C#
<protected void="" gridviewroweventargs="" mode="hold" />    {

        try
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.Header:
                    //...
                    break;
                case DataControlRowType.DataRow:
  e.Row.Cells[3].Attributes.Add("onmouseover", "showImage()");
                    e.Row.Cells[3].Attributes.Add("onmouseout", "hideImage()");

                                  HyperLink lnkbtn = new HyperLink();
                        lnkbtn.Text = "view";
                        e.Row.Cells[3].Controls.Add(lnkbtn);
                        //e.Row.Cells[3].Style
                        lnkbtn.NavigateUrl = @"Credtional\editcustomer.aspx";
                        e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(gvCustomers, "Select$" + e.Row.RowIndex.ToString()));
                    break;
            }
        }
        catch (Exception ex)
        {

        }
    }


My aspx code

ASP.NET
<script type="text/javascript">
    function showImage() {
        document.getElementById("image").style.display = "inline";
        document.getElementById("image").src = 'images/Qtrimage1.png';
    }
    function hideImage() {
        document.getElementById("image").style.display = "none";
        document.getElementById("image").src = 'images/Qtrimage2.png';
    }
   </script>

 <asp:gridview id="gvCustomers" 
     onrowdatabound="gvCustomers_RowDataBound" AutoGenerateColumns="true" 
    runat="server" onselectedindexchanged="gvCustomers_SelectedIndexChanged">

 
          <img src="images/Qtrimage.png" id="image" alt="" width="30px" height="30px" style="display:none;"/>


But i am not able to achieve it.Kindly help me out.
Posted
Updated 13-Jan-15 6:56am
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-15 13:04pm    
Do you want to post-back on mouse hover? It could be a serious performance leak. Would you rather prefer handling it all on the client side, which could be done in a rather trivial way?
—SA
@Parakka 6-Mar-20 9:32am    
How to do that
Did you debug and see if it is coming into the JavaScript method showImage()?
Dhirendra Kumar 13-Jan-15 14:35pm    
can you help me some relevant solution to do it.

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