private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {
if ( e.Item.ItemType == ListItemType.Header ) {
TableCellCollection tcl = e.Item.Cells;
tcl.Clear();
tcl.Add( new TableHeaderCell() );
tcl[0].RowSpan = 2;
tcl[0].Text = "资料项目";
tcl.Add( new TableHeaderCell() );
tcl[1].ColumnSpan = 2;
tcl[1].Text = "会计科目</th></tr><tr><th>借</th><th>贷";
}
}
两层表头,多层可以照此做
if ( e.Item.ItemType == ListItemType.Header ) {
TableCellCollection tcl = e.Item.Cells;
tcl.Clear();
tcl.Add( new TableHeaderCell() );
tcl[0].RowSpan = 2;
tcl[0].Text = "资料项目";
tcl.Add( new TableHeaderCell() );
tcl[1].ColumnSpan = 2;
tcl[1].Text = "会计科目</th></tr><tr><th>借</th><th>贷";
}
}
两层表头,多层可以照此做