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;
            }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值