Solved

asp.net mouse over highlight on gridview with updatepanel grid

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 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

6 Experts available now in Live!

Get 1:1 Help Now