当前位置: 代码迷 >> ASP.NET >> 如何把gridview两个列单元框合并?或者合并两个列头也行
  详细解决方案

如何把gridview两个列单元框合并?或者合并两个列头也行

热度:3345   发布时间:2013-02-25 00:00:00.0
怎么把gridview两个列单元框合并?或者合并两个列头也行
怎么把gridview两个列单元框合并?或者合并两个列头也行

------解决方案--------------------------------------------------------
使用GV的自定义表头
在GV的RowCreated事件里
C# code
 #region        switch (e.Row.RowType)        {            case DataControlRowType.Header:                //第一行表头                TableCellCollection tcHeader = e.Row.Cells;                tcHeader.Clear();                tcHeader.Add(new TableHeaderCell());                //tcHeader[0].Style = "font-family:@MS Gothic";                tcHeader[0].Attributes.Add("rowspan", "3"); //跨Rowborder:1; ;                //tcHeader[0].Attributes.Add("bgcolor", "white");                tcHeader[0].Text = "社区";                tcHeader[0].Style.Value = "border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: \"宋体\";font-size: 12px;font-weight: bold;";}#endregion
------解决方案--------------------------------------------------------
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行表头
TableCellCollection tcHeader = e.Row.Cells;
tcHeader.Clear();
tcHeader.Add(new TableHeaderCell());
//tcHeader[0].Style = "font-family:@MS Gothic";
tcHeader[0].Attributes.Add("rowspan", "3"); //跨Rowborder:1; ;
//tcHeader[0].Attributes.Add("bgcolor", "white");
tcHeader[0].Text = "社区";
tcHeader[0].Style.Value = "border-bottom-color: #333333;border-right-color: #999999;height: 25px;font-family: \"宋体\";font-size: 12px;font-weight: bold;";
}
RowsCreated事件中
  相关解决方案