repeater合并单元格

HTML:

<asp:Repeater ID="rep1" runat="server">
<HeaderTemplate>
<table width="100%" class="table">
<tr>
<td>评估项目</td>
<td>评估内容</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td id="td1" runat="server"><%#Eval("item") %></td>
<td><%#Eval("content") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>C# code:

 

C# code:

string sql = "select * from test";
        rep1.DataSource = DbManager.ExecuteQuery(sql);
        rep1.DataBind();
        for (int i = rep1.Items.Count - 1; i > 0; i--)
        {
            HtmlTableCell oCell_previous = rep1.Items[i - 1].FindControl("td1") as HtmlTableCell;
            HtmlTableCell oCell = rep1.Items[i].FindControl("td1") as HtmlTableCell;

            oCell.RowSpan = (oCell.RowSpan == -1) ? 1 : oCell.RowSpan;
            oCell_previous.RowSpan = (oCell_previous.RowSpan == -1) ? 1 : oCell_previous.RowSpan;

            if (oCell.InnerText == oCell_previous.InnerText)
            {
                oCell.Visible = false;
                oCell_previous.RowSpan += oCell.RowSpan;
            }
        }

你可能感兴趣的:(repeater合并单元格)