2012-07-03 120 views
1

我有gridview,其中包含合并的单元格和列。 我想分开一个单元来分开部分,但没有运气。 基本上下面的图片显示了我想要实现的。将列划分为多个部分 - Gridview

enter image description here

目前我的第一张图片结构,我想这是像第二张照片。 (在图像中,我只将前两列中的列分开,但我期望它在整个网格中。)

基本上来自第2列和其他将包含日期作为标题。所以我想把两天的时间分成几部分。

Col2(1/1/2012)   | Col3(7/1/2012) 
This col will split | 
in to 6 sections (7-1) | 

任何帮助是赞赏! 。

感谢

+0

+1为美丽的自由手excel像广场。 – JonH

回答

0

我已经通过合并第一行的行数据实现了它。

我已经根据日期差异和一组日期差异添加了新列,我添加了相同的列标题,它们将它们合并在一起。

0

选项1" 可以以表格的形式建立一个HTML字符串,并将其绑定到网格后面的代码中做到这一点

sb.Append("<table style=\"width: 100%;\"> "); 


for (int i = 0; i < cnt;i++) 
     { 
      col1=""; 
      col2=""; 
      col3=""; 

      String fmt= @"<tr> 
          <td style='width: 33%;' > 
           <b>{0}</b> 
          </td> 
          <td style='width: 33%;'> 
           {1} 
          </td> 
          <td style='width: 33%;' > 
           {2} 
          </td> 
         </tr>"; 

      col1 = row[i].col1 ; 
      col2 = row[i].col2 ; 
      col3 = row[i].col3 ; 

      sb.AppendFormat(fmt, col1,col2,col3); 
     } 
     sb.Append("</table>"); 

选项2: (或者你可以在aspx页面的gridview中使用表格格式)

<ItemTemplate> 

<div class="innerTable"> 
<table> 
    <tr > 
     <td ></td> 
     <td ></td> 
    </tr> 
    <tr> 
     <td></td> 
     <td></td> 
    </tr> 
</table> 
</div> 
</ItemTemplate> 
+0

ops ..如果您错过理解,请联系!这不是asp.net,它是一个winform应用程序 –