日期:2014-05-17 浏览次数:20423 次
using System.Drawing;
using System.Web.UI.WebControls;
namespace MyControls
{
public class GridView : System.Web.UI.WebControls.GridView
{
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
var table = (Table)this.Controls[0];
var row = new TableRow();
table.Rows.AddAt(0, row);
var cell = new TableHeaderCell { Text = "组标题1", ColumnSpan = 2, BackColor = Color.AliceBlue };
row.Cells.Add(cell);
cell = new TableHeaderCell { Text = "组标题2", ColumnSpan = 2, CssClass = "titleStyle2" };
row.Cells.Add(cell);
cell = new TableHeaderCell { Text = "标题3" };
row.Cells.Add(cell);
base.RenderContents(writer);
}
}
}
<%@ Register TagPrefix="mc" Namespace="MyControls" %>
<ASP:GridView ....改为
<mc:GridView ....即可。