动态合并DataGrid表头栏位


在ItemCreate 事件中加入以下代码:

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>";

}

}

相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2021-11-17
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-11-18
  • 2021-05-21
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2021-11-10
  • 2021-08-31
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案