2012-07-03 27 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應用程序 –