asp.net table/gridview 合并列

        public void MergeCell(TableRow trow)
        {
            TableCell currentCell = trow.Cells[0];
            TableCell prevCell = null;
            for (var i = 0; i < trow.Cells.Count; i++)
            {
                currentCell = trow.Cells[i];
                if (prevCell != null && currentCell.Text == prevCell.Text)
                {
                    prevCell.ColumnSpan = (prevCell.ColumnSpan == 0 ? 1 : prevCell.ColumnSpan) + 1;
                    currentCell.Visible = false;
                }
                else
                {
                    prevCell = currentCell;
                }
            }
        }

 

posted @ 2016-01-25 09:11  长脖子羊  阅读(460)  评论(0编辑  收藏  举报