Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to have keyevent and mouseevent to select a rows on a gridview control which is placed inside a updatepanel(update in every 1 seconds). I am able to have the mouse event not able to perform keyevent on the gridview. please help.
Here is the code that I am using

//C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = 
                "javascript:setMouseOverColor(this);";
            e.Row.Attributes["onmouseout"] = 
                "javascript:setMouseOutColor(this);";
            e.Row.Attributes["onclick"] = 
            ClientScript.GetPostBackClientHyperlink
                (this.GridView1, "Select$" + e.Row.RowIndex);


            
        }
    }


//JavaScript code
XML
<script language="javascript" type="text/javascript">
       var oldgridSelectedColor;

       function setMouseOverColor(element)
       {
           oldgridSelectedColor = element.style.backgroundColor;
           element.style.backgroundColor='yellow';
           element.style.cursor='hand';
           element.style.textDecoration='underline';
       }

       function setMouseOutColor(element)
       {
           element.style.backgroundColor=oldgridSelectedColor;
           element.style.textDecoration='none';
       }
   </script>
Posted
Updated 28-Dec-12 22:56pm
v2

1 solution

There are some tricks using GridView in an UpdatePanel:
Using Gridview in UpdatePanel[^]
 
Share this answer
 

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