【 tulaoshi.com - ASP.NET 】
1.简单的DataGrid多表头制做!!!
可在html中的datagrid的最后绑定列中写
HeaderText=okdd看加的页眉总头的多少而写td的多少!然后在代码中写:private void dgrBasic_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Header)
{
//e.Item.Cells[0].RowSpan = 2;
e.Item.Cells[1].RowSpan = 2;
e.Item.Cells[2].RowSpan = 2;
e.Item.Cells[3].RowSpan = 2;
e.Item.Cells[4].RowSpan = 2;
e.Item.Cells[5].RowSpan = 2;
e.Item.Cells[6].ColumnSpan = 4;
e.Item.Cells[7].Visible = false;
e.Item.Cells[8].Visible = false;
e.Item.Cells[9].Visible = false;
e.Item.Cells[10].RowSpan = 2;
e.Item.Cells[11].RowSpan = 2;
e.Item.Cells[12].RowSpan = 2;
e.Item.Cells[13].ColumnSpan = 3;
e.Item.Cells[14].Visible = false;
e.Item.Cells[15].Visible = false;
e.Item.Cells[16].RowSpan = 2;
}
}
就是这么简单,如果想了解详细还需自己体会!