Repeater 合并一列中内容相同的单元格

        /// <summary>
        /// 合并一列中内容相同的单元格
        /// </summary>
        /// <param name="strColName">列名</param>
        /// <param name="rpList">Repeater控件名</param>
        public static void MergerCell(string strColName,Repeater rpList)
        {
            for (int i = rpList.Items.Count - 1; i > 0; i--)
            {
                HtmlTableCell oCell_previous = rpList.Items[i - 1].FindControl(strColName) as HtmlTableCell;
                HtmlTableCell oCell = rpList.Items[i].FindControl(strColName) 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;
                }
            }
        }

 

前台页面:对应 Repeater 的td内需加,如:

<td runat="server" id="tdRiverName"><%# Eval("RiverName")%></td>

发布了66 篇原创文章 · 获赞 2 · 访问量 6万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览