码迷,mamicode.com
首页 > 其他好文 > 详细

Repeater 合并单元格

时间:2018-11-19 15:08:51      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:als   serve   state   nat   innertext   beef   pre   his   gate   

aspx:

<table class="tableSearch" style="width: 760px; border: none">
                <tr style="background-color: #EBEEF4; font-size: 13px; font-weight: bold;">
                    <td style="height: 26px;" align="center">
                        订单编号
                    </td>
                    <td style="text-align: center;">
                        PNR
                    </td>
                    <td>
                        乘客姓名
                    </td>
                    <td style="text-align: center;">
                        旧证件号
                    </td>
                    <td style="text-align: center;">
                        新证件号
                    </td>
                    <td style="text-align: center;">
                        请求时间
                    </td>
                    <td style="text-align: center;">
                        处理时间
                    </td>
                    <td>
                        状  态
                    </td>
                </tr>
                <asp:Repeater ID="rprHis" runat="server">
                    <ItemTemplate>
                        <tr style="background-color: #FFFFFF; font-size: 13px;">
                            <td id="HisOrder" runat="server" style="height: 26px; text-align: center;">
                                <asp:HyperLink ID="OrderLink" NavigateUrl=<%# "~/Application/DisplayOrder.aspx?OrderNo=" + Eval("OrderNo") %>
                                    runat="server" Text=<%# Eval("OrderNo") %>> </asp:HyperLink>
                            </td>
                            <td id="HisPNR" runat="server" style="text-align: center;">
                                <%# Eval("pnr") %>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="LabPassengerName" runat="server" Text=<%#Eval("PassengerName") %>></asp:Label>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="Label3" runat="server" Text=<%# Bind("OldCardNo") %>></asp:Label>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="Label4" runat="server" Text=<%# Bind("NewCardNo") %>></asp:Label>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="Label5" runat="server" Text=<%# Bind("RequestTime") %>></asp:Label>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="Label6" runat="server" Text=<%# Bind("ModifyTime") %>></asp:Label>
                            </td>
                            <td style="text-align: center;">
                                <asp:Label ID="Label1" runat="server" Text=<%# GetState(Eval("RequestState").ToString()) %>></asp:Label>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>

合并代码:

for (int i = rprHis.Items.Count - 1; i > 0; i--)
            {
                HtmlTableCell oCell_item2 = rprHis.Items[i - 1].FindControl("HisPNR") as HtmlTableCell;

                HtmlTableCell oCell_item1 = rprHis.Items[i].FindControl("HisPNR") as HtmlTableCell;

                oCell_item1.RowSpan = (oCell_item1.RowSpan == -1) ? 1 : oCell_item1.RowSpan;
                oCell_item2.RowSpan = (oCell_item2.RowSpan == -1) ? 1 : oCell_item2.RowSpan;

                if (oCell_item1.InnerText == oCell_item2.InnerText)
                {
                    oCell_item1.Visible = false;
                    oCell_item2.RowSpan += oCell_item1.RowSpan;
                }

                HtmlTableCell oCell2_item2 = rprHis.Items[i - 1].FindControl("HisOrder") as HtmlTableCell;

                HtmlTableCell oCell2_item1 = rprHis.Items[i].FindControl("HisOrder") as HtmlTableCell;

                oCell2_item1.RowSpan = (oCell2_item1.RowSpan == -1) ? 1 : oCell2_item1.RowSpan;
                oCell2_item2.RowSpan = (oCell2_item2.RowSpan == -1) ? 1 : oCell2_item2.RowSpan;

                HyperLink hl1 = rprHis.Items[i - 1].FindControl("OrderLink") as HyperLink;
                HyperLink hl2 = rprHis.Items[i].FindControl("OrderLink") as HyperLink;
                if (hl1.Text == hl2.Text)//必须用这个判断td中不再是文本而是HyperLink控件
                {
                    oCell2_item1.Visible = false;
                    oCell2_item2.RowSpan += oCell2_item1.RowSpan;
                }

            }

 

Repeater 合并单元格

标签:als   serve   state   nat   innertext   beef   pre   his   gate   

原文地址:https://www.cnblogs.com/wanggang-java/p/9983117.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!