Gridview后台添加滑动效果

来源:互联网 发布:如何安装pyqt4 linux 编辑:程序博客网 时间:2024/06/06 00:20
 

GridView1_RowDataBound事件在对行进行了数据绑定后激发。

e.Row.RowType判断行的类型。

DataControlRowType选择行的类型

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                caseDataControlRowType.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
                        {
                            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;
            }
        }

原创粉丝点击