zoukankan      html  css  js  c++  java
  • Repeater 合并单元格

    aspx:

    <table class="tableSearch" style=" 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;
                    }
    
                }
  • 相关阅读:
    深入剖析ASP.NET的编译原理之一:动态编译(Dynamical Compilation)
    ASP.NET Process Model之二:ASP.NET Http Runtime Pipeline Part I
    IIS Server Variables(IIS 服务器变量)
    .Net源码之Page类(二)
    博客改变生活
    目录、路径、虚拟路径
    Windows 7 Beta 1 7000
    《Visual Studio Hacks 》读书笔记 (十二)
    新建XML文件
    另一个分页函数
  • 原文地址:https://www.cnblogs.com/wanggang-java/p/9983117.html
Copyright © 2011-2022 走看看