首页 > 代码库 > Gridview单双行

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
        }