三层表头书写
protected void gdvOpenAR_RowDataBound(object sender, GridViewRowEventArgs e)
{
ColorConverter ccv = new ColorConverter();
Color colorBlue = (Color)ccv.ConvertFromString("#006892"); // 表头color
//重写表头,三层.
if (e.Row.RowType == DataControlRowType.Header)
{
//第一行表头
TableCellCollection tcl = e.Row.Cells;
tcl.Clear();
tcl.Add(new TableHeaderCell());
tcl[0].RowSpan = 3;
tcl[0].Text = "CUSTOMER";
tcl[0].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[1].Text = "Standard Payment Term" ;
tcl[1].RowSpan = 3;
tcl[1].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[2].Text = "Credit Limite(K USD)";
tcl[2].RowSpan = 3;
tcl[2].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[3].Text = "Open AR(K USD)";
tcl[3].RowSpan = 3;
tcl[3].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[4].Text = "Avg. Coll. Day";
tcl[4].RowSpan = 3;
tcl[4].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[5].Text = "Receipt Amount(K USD)";
tcl[5].RowSpan = 3;
tcl[5].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[6].Text = "Total AR - Interest Cost";
tcl[6].ColumnSpan = 4;
tcl[6].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[7].Text = "Overdue AR - Interest Cost";
tcl[7].ColumnSpan = 4;
tcl[7].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[8].Text = "Non Overdue AR - Interest Cost" + "</th></tr><tr>"; //是第一层最后一列
tcl[8].ColumnSpan = 4;
tcl[8].BackColor = colorBlue;
//第二行表头
tcl.Add(new TableHeaderCell());
tcl[9].ColumnSpan = 2;
tcl[9].Text = "Aug.";
tcl[9].HorizontalAlign = HorizontalAlign.Center;
tcl[9].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[10].ColumnSpan = 2;
tcl[10].Text = "Jul.";
tcl[10].HorizontalAlign = HorizontalAlign.Center;
tcl[10].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[11].ColumnSpan = 2;
tcl[11].Text = "Aug.";
tcl[11].HorizontalAlign = HorizontalAlign.Center;
tcl[11].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[12].ColumnSpan = 2;
tcl[12].Text = "Jul.";
tcl[12].HorizontalAlign = HorizontalAlign.Center;
tcl[12].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[13].ColumnSpan = 2;
tcl[13].Text = "Aug.";
tcl[13].HorizontalAlign = HorizontalAlign.Center;
tcl[13].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[14].ColumnSpan = 2;
tcl[14].Text = "Jul.</th></tr><tr>"; //是第二层最后一列
tcl[14].HorizontalAlign = HorizontalAlign.Center;
tcl[14].BackColor = colorBlue;
//第三行表头
tcl.Add(new TableHeaderCell());
tcl[15].Text = "Total(KUSD)";
tcl[15].HorizontalAlign = HorizontalAlign.Center;
tcl[15].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[16].Text = "Per Watt";
tcl[16].HorizontalAlign = HorizontalAlign.Center;
tcl[16].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[17].Text = "Total(KUSD)";
tcl[17].HorizontalAlign = HorizontalAlign.Center;
tcl[17].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[18].Text = "Per Watt";
tcl[18].HorizontalAlign = HorizontalAlign.Center;
tcl[18].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[19].Text = "Total(KUSD)";
tcl[19].HorizontalAlign = HorizontalAlign.Center;
tcl[19].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[20].Text = "Per Watt";
tcl[20].HorizontalAlign = HorizontalAlign.Center;
tcl[20].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[21].Text = "Total(KUSD)";
tcl[21].HorizontalAlign = HorizontalAlign.Center;
tcl[21].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[22].Text = "Per Watt";
tcl[22].HorizontalAlign = HorizontalAlign.Center;
tcl[22].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[23].Text = "Total(KUSD)";
tcl[23].HorizontalAlign = HorizontalAlign.Center;
tcl[23].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[24].Text = "Per Watt";
tcl[24].HorizontalAlign = HorizontalAlign.Center;
tcl[24].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[25].Text = "Total(KUSD)";
tcl[25].HorizontalAlign = HorizontalAlign.Center;
tcl[25].BackColor = colorBlue;
tcl.Add(new TableHeaderCell());
tcl[26].Text = "Per Watt</th></tr>";
tcl[26].HorizontalAlign = HorizontalAlign.Center;
tcl[26].BackColor = colorBlue;
}