我想实现隔行插入标头的样式,
            int countRow = this.GridView.Rows.Count;
           
                GridViewRow header = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
                header = this.GridView.HeaderRow;
            
                this.GridView.Controls[0].Controls.AddAt(5, header);
                this.GridView.Controls[0].Controls.AddAt(7, header);
           
本想在第5和第7行实现复制标头,但结果只在第7行显示了标头,而且原来的标头也不见了,实际上是标头移到了第7行,不知是为什么,怎么实现呢

解决方案 »

  1.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >0 &&  (e.Row.RowIndex+1) % 10 == 0)
            {
                GridViewRow newRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);            foreach (TableCell hc in this.GridView1.HeaderRow.Cells)
                {
                    TableCell c = new TableCell();
                    c.Text = hc.Text;
                    hc.CopyBaseAttributes(c);
                    newRow.Cells.Add(c);
                }
                this.GridView1.Controls[0].Controls.Add(newRow);
            }
        }
      

  2.   

    谢谢白兄,但是有一个问题呀,可以显示,但是导出的EXCEl却是空行
    什么原因呢