Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net mouse over highlight on gridview with updatepanel grid

Posted on 2014-03-16
3
Medium Priority
?
607 Views
Last Modified: 2014-03-28
trying to display
highlight on gridview while mouseover with

protected void gvHrEmploye_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
            {

                // when mouse is over the row, save original color to new attribute, and change it to highlight color
                e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFFAA'");

                // when mouse leaves the row, change the bg color to its original value  
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;");


            }
        }

Open in new window


currently not achievable,
was wondering whether the gridview with update panel does not work
tried several methods with the hover,
0
Comment
Question by:doramail05
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39933782
You could just use a simple CSS style to achieve the same thing:
<style type="text/css">

    tr { background-color: <your default colour>; }
    tr:hover { background-color: #EEFFAA }

</style>

Open in new window

You may need to be a little more explicit in the path for the style if you have multiple grids on the page if you only want the effect applied to one of them.
0
 
LVL 1

Accepted Solution

by:
doramail05 earned 0 total points
ID: 39949366
worked with this :

protected void gvProduct_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvProduct, "Select$" + e.Row.RowIndex);
            e.Row.Attributes.Add("onmouseover", "HighLightMe(this);");
            e.Row.Attributes.Add("onmouseout", "UnHighLightMe(this);");
        }
    }

  <script type="text/javascript">
       
        function HighLightMe(row) {
            row.originalColor = row.style.backgroundColor;
            row.style.backgroundColor = '#F8F2AF';
        }

        function UnHighLightMe(row) {
            row.style.backgroundColor = row.originalColor;
        }
    </script>
0
 
LVL 1

Author Closing Comment

by:doramail05
ID: 39961062
got it worked
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 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