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;
                    }
    
                }
  • 相关阅读:
    ES6新特性
    CSS + HTML 鼠标在图片上悬停时的显示文字,移走时文字消失
    APICloud closeToWin和closeWin的使用
    基于vue-cli配置移动端自适应
    Cookies,localStorage,sessionStorage,Web SQL Database(客户端)会话存储学习
    select标签默认选择选项
    MySQL数据库的配置
    jsp定义 ,JSON对象
    eclipse配置
    VS2017 C++编译时出现 "the windows sdk version for 8.1 was not found"解决办法(亲测有效)
  • 原文地址:https://www.cnblogs.com/wanggang-java/p/9983117.html
Copyright © 2011-2022 走看看