1

我有包含合并单元格和列的gridview。我试图将一个单元格分成不同的部分,但没有运气。基本上下图显示了我想要实现的目标。

在此处输入图像描述

目前我有第一张图片结构,我希望它像第二张图片。(在图像中,我只将前 2 行中的列分开,但我希望它在整个网格中。)

基本上来自第 2 列和其他将包含一个日期作为标题。所以我希望将两天的差异分成不同的部分。

例如

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

任何帮助表示感谢!

谢谢

4

2 回答 2

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>
于 2012-07-04T03:18:25.850 回答
0

我通过合并第一行的行数据来实现它。

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

于 2012-07-04T10:28:26.293 回答