当前位置:编程学习 > asp >>

Gridview后台添加滑动效果

GridView1_RowDataBound事件在对行进行了数据绑定后激发。
e.Row.RowType判断行的类型。
DataControlRowType选择行的类型
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.Header:
                    break;
                case DataControlRowType.DataRow:
                    if (e.Row.RowIndex > -1)
                    {
                        // 奇数行
                        if (e.Row.RowIndex % 2 == 0)
                        {
                            e.Row.Attributes.Add
                           ("onmouseover", "this.style.backgroundColor='#84AAEF';
                           this.style.color='white'");
                            e.Row.Attributes.Add             
                            ("onmouseout", "this.style.backgroundColor='#F7F6F3';
                            this.style.color='#333333'");
                        }
                        else www.zzzyk.com
                        {
                            e.Row.Attributes.Add
                           ("onmouseover", "this.style.backgroundColor='#84AAEF';
                            this.style.color='white'");
                            e.Row.Attributes.Add
                           ("onmouseout", "this.style.backgroundColor='#F7F6F3';
                           this.style.color='#333333'");
                        }
                    }
                    break;
            }
        }

摘自 徐越的专栏
补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,