zoukankan      html  css  js  c++  java
  • repeater相同行合并

    代码
    <table  width="100%"    id="mytable" >
        
    <tr align="center">
          
    <th>学号</th><th>姓名</th><th>起止时间</th> <th>学习(或工作)单位</th> <th>职务</th> <th>证明人</th> <th>备注</th>
        
    </tr>
        
    <asp:Repeater ID="Repeater1" runat="server" onprerender="Repeater1_PreRender">
        
    <ItemTemplate>
        
    <tr><td id="tdxuehao" runat="server">&nbsp;<%#Eval("xuehao"%></td><td id="tdxsname" runat="server">&nbsp;<%#Eval("xsname")%></td><td>&nbsp;<%#Eval("qzsj")%></td> <td>&nbsp;<%#Eval("grjl")%></td> <td>&nbsp;<%#Eval("zw")%></td> <td>&nbsp;<%#Eval("zmr")%></td> <td>&nbsp;<%#Eval("bz")%></td>
        
    </tr>
        
    </ItemTemplate>
        
    </asp:Repeater>
        
           
    </table>
    代码
    protected void Repeater1_PreRender(object sender, EventArgs e)
            {
                
    for (int i = Repeater1.Items.Count - 1; i > 0; i--)
                {
                    
    //tcid是需要合并列的列名
                    HtmlTableCell oCell_previous = Repeater1.Items[i - 1].FindControl("tdxuehao"as HtmlTableCell;
                    HtmlTableCell oCell 
    = Repeater1.Items[i].FindControl("tdxuehao"as HtmlTableCell;
                    
    if (oCell_previous != null && oCell != null)
                    {
                        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;
                        }
                    }


                    HtmlTableCell nameprevious 
    = Repeater1.Items[i - 1].FindControl("tdxsname"as HtmlTableCell;
                    HtmlTableCell name 
    = Repeater1.Items[i].FindControl("tdxsname"as HtmlTableCell;
                    
    if (nameprevious != null && name != null)
                    {
                        name.RowSpan 
    = (name.RowSpan == -1? 1 : name.RowSpan;
                        nameprevious.RowSpan 
    = (nameprevious.RowSpan == -1? 1 : nameprevious.RowSpan;

                        
    if (name.InnerText == nameprevious.InnerText)
                        {
                            name.Visible 
    = false;
                            nameprevious.RowSpan 
    += name.RowSpan;
                        }
                    }
                }


            }
  • 相关阅读:
    MySQL 重要参数 innodb_flush_log_at_trx_commit 和 sync_binlog
    mysql物理日志和逻辑日志_mysql物理日志redo log和逻辑日志 binlog
    Navicat Premium for Mac 破解版
    qps是什么
    如何实现扫码登录功能?
    goland debug
    [Golang] 初探之 sync.Once
    go语言:sync.Once的用法
    Golang进程权限调度包runtime三大函数Gosched,Goexit,GOMaXPROCS
    Go unsafe 包之内存布局
  • 原文地址:https://www.cnblogs.com/luyesql/p/1864580.html
Copyright © 2011-2022 走看看