Solved

asp.net mouse over highlight on gridview with updatepanel grid

Posted on 2014-03-16
3
579 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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