·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> GridView 自定义表头
//修改表头 PRotected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header:
TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear();
//第一行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[0].Text = "日期"; tcHeader[0].Attributes.Add("rowspan","2");
tcHeader.Add(new TableHeaderCell()); tcHeader[1].Text = "星期"; tcHeader[1].Attributes.Add("rowspan", "2");
tcHeader.Add(new TableHeaderCell()); tcHeader[2].Text = "白班"; tcHeader[2].Attributes.Add("colspan", "2");
tcHeader.Add(new TableHeaderCell()); tcHeader[3].Text = "夜班</th></tr><tr>"; tcHeader[3].Attributes.Add("colspan", "2");
//第二行表头 tcHeader.Add(new TableHeaderCell()); tcHeader[4].Text = "姓名";
tcHeader.Add(new TableHeaderCell()); tcHeader[5].Text = "部门";
tcHeader.Add(new TableHeaderCell()); tcHeader[6].Text = "姓名";
tcHeader.Add(new TableHeaderCell()); tcHeader[7].Text = "部门";
break; } }