Solved

asp.net mouse over highlight on gridview with updatepanel grid

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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 …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now