Gridview单双行

.table01_singlar
        {
            background-color: #FFFFFF;
        }
.table01_double
        {
            background-color: #e5eaf0;
        }

OnRowDataBound="gvData_RowDataBound"

        protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           //添加样式-----------begin
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                    if (e.Row.RowIndex > -1)
                    {
                        // 奇数行
                        if (e.Row.RowIndex % 2 == 0)
                        {
                            e.Row.CssClass = "table01_singlar";
                        }
                        else
                        {
                            e.Row.CssClass = "table01_double";
                        }
                    }
                    break;
            }
            //------------------end
        }

posted @ 2014-07-25 13:16  裸奔的豆子  阅读(192)  评论(0编辑  收藏  举报