日期:2014-05-18 浏览次数:20969 次
protected void GridView1_RowCreated( object sender , GridViewRowEventArgs e )
    {
        TableCellCollection tcRow = e.Row.Cells;
        switch(e.Row.RowType)
        {
            case DataControlRowType.Header:
                GridViewRow newrow=new GridViewRow(0,0, DataControlRowType.Header,DataControlRowState.Normal);
                newrow.Visible=true;
                for(int i=0;i<tcRow.Count;i++)
                {
                    TableCell tc=new TableCell();
                    tc.Text=tcRow[i].Text;
                    tc.VerticalAlign=VerticalAlign.Middle;
                    tc.HorizontalAlign=HorizontalAlign.Center;
                    newrow.Cells.Add(tc);
                }
                newrow.Cells[0].RowSpan=2;
                newrow.Cells[1].RowSpan=2;
                newrow.Cells[2].RowSpan=2;
                newrow.Cells[3].RowSpan=2;
                newrow.Cells[4].RowSpan=2;
                newrow.Cells[5].ColumnSpan=2;
                newrow.Cells.RemoveAt(6);
                newrow.Cells[6].RowSpan=2;
                newrow.Cells[7].ColumnSpan=2;
                newrow.Cells.RemoveAt(8);
                newrow.Cells[8].ColumnSpan=2;
                newrow.Cells.RemoveAt(9);
                newrow.Cells[9].ColumnSpan=2;
                newrow.Cells.RemoveAt(10);
                newrow.Cells[10].ColumnSpan=2;
                newrow.Cells.RemoveAt(11);
                newrow.Cells[11].RowSpan=2;
                newrow.Cells[12].RowSpan=2;
                tcRow[0].Text="Min";
                tcRow[1].Text="Max";
                tcRow[2].Text="Min";
                tcRow[3].Text="Max";
                tcRow[4].Text="Min";
                tcRow[5].Text="Max";
                tcRow[6].Text="Min";
                tcRow[7].Text="Max";
                tcRow[8].Text="Min";
                tcRow[9].Text="Max";
                for ( ; tcRow.Count > 10; )
                {
                    tcRow.RemoveAt( 10 );
                }
                GridView1.Controls[0].Controls.AddAt(0,newrow);
                break;
                
            case DataControlRowType.DataRow:
                break;
        }
}