码迷,mamicode.com
首页 > 其他好文 > 详细

GridView显示数据鼠标悬停变色

时间:2014-07-06 10:48:59      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:style   color   数据   type   ar   view   

 一、 首先在前台GridView中加上onrowdatabound="GridView1_RowDataBound":

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        onrowdatabound="GridView1_RowDataBound">

   .......

 </asp:GridView>

二、然后在后台的GridView1_RowDataBound事件中写

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {


                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor=‘#99FFCC‘");     //鼠标悬停变色
              
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");      //鼠标移走颜色还原
            }
        }

GridView显示数据鼠标悬停变色,布布扣,bubuko.com

GridView显示数据鼠标悬停变色

标签:style   color   数据   type   ar   view   

原文地址:http://blog.csdn.net/zhangkang_/article/details/36909995

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!