呵呵 很简单的 照着我给你这个写就可以了
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].Attributes.Add("rowspan", "2"); //跨Row
tcHeader[0].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[0].Text = "月份";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[1].Attributes.Add("colspan", "3"); //跨Column
tcHeader[1].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[1].Text = "耗油情况总量(单位:元)";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[2].Attributes.Add("rowspan", "2");
tcHeader[2].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[2].Text = "实际耗油总量";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[3].Attributes.Add("rowspan", "2");
tcHeader[3].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[3].Text = "操作</th></tr><tr style='color:#FFFFFF'>";
//第二行表头
tcHeader.Add(new TableHeaderCell());
tcHeader[4].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[4].Text = "油耗额定总量";
tcHeader.Add(new TableHeaderCell());
tcHeader[5].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[5].Text = "节支总量";
tcHeader.Add(new TableHeaderCell());
tcHeader[6].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[6].Text = "超支总量(长途油耗)"; break;
}
}
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].Attributes.Add("rowspan", "2"); //跨Row
tcHeader[0].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[0].Text = "月份";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[1].Attributes.Add("colspan", "3"); //跨Column
tcHeader[1].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[1].Text = "耗油情况总量(单位:元)";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[2].Attributes.Add("rowspan", "2");
tcHeader[2].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[2].Text = "实际耗油总量";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[3].Attributes.Add("rowspan", "2");
tcHeader[3].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[3].Text = "操作</th></tr><tr style='color:#FFFFFF'>";
//第二行表头
tcHeader.Add(new TableHeaderCell());
tcHeader[4].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[4].Text = "油耗额定总量";
tcHeader.Add(new TableHeaderCell());
tcHeader[5].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[5].Text = "节支总量";
tcHeader.Add(new TableHeaderCell());
tcHeader[6].Attributes.Add("bgcolor", "#1c67bc");
tcHeader[6].Text = "超支总量(长途油耗)"; break;
}
}
解决方案 »
- 紧急求救(发邮件不成功)
- 问一个比较弱的问题,Access数据库中删除一条记录时提示“标准表达式中数据类型不匹配”???
- 问一个SQL查询语句
- 急!数据库问题,请高手指教,谢谢!
- word表格的智能识别和自动填写?
- 谁能教我如何在ASP.NET里面使用OLEDB的连接方式使用ORACLE的存储过程?多谢
- 各位,在VS2003中怎么调试ASP.net程序急啊
- ASP.NET中怎么连接到SQL SERVER数据库呀!
- 请问与 newid() 产生的字段,用字符串怎么跟它比较,急!谢谢!
- 一个奇怪的问题,应该是ViewStat相关的
- 使用ajaxpro后的server.mappath()
- 我想用asp.net做个合同到期提示的功能,望不吝赐教。
只有datagridview控件,没有gridview控件