如何在gridview中合并asp.net中的一列的行 [英] how to merge rows of one column in asp.net in gridview

查看:121
本文介绍了如何在gridview中合并asp.net中的一列的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i有一个gridview,我想在一列中合并具有相同值的单元格



i有8列,但我想在第一列合并单元格



我该怎么做



thnx提前

hi

i have a gridview , i want to merge cells with a same value in one column

i have 8 columns , but i want to merge cells on column number one

how can i do this

thnx in advance

推荐答案

有很多很好的例子。例如:

- 如何在GridView中合并具有相等值的单元格 [ ^ ]

- ASP.NET GridView控件中的行和列合并 [ ^ ]

和所以...



附加:

合并第一栏(基于第一篇文章中的代码)

There are a lot of good examples. For example:
- How to merge cells with equal values in a GridView[^]
- Rows and Columns Merging in ASP.NET GridView Control[^]
and so on...

ADDITION:
merge just 1st column (based on the code in first article)
public static void MergeRows(GridView gridView)
    {
        for (int rowIndex = gridView.Rows.Count - 2; rowIndex >= 0; rowIndex--)
        {
            GridViewRow row = gridView.Rows[rowIndex];
            GridViewRow previousRow = gridView.Rows[rowIndex + 1];

            if (row.Cells[0].Text == previousRow.Cells[0].Text)
            {
                row.Cells[0].RowSpan = previousRow.Cells[0].RowSpan < 2 ? 2 : 
                                       previousRow.Cells[0].RowSpan + 1;
                previousRow.Cells[0].Visible = false;
            }
        }
    }


这篇关于如何在gridview中合并asp.net中的一列的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆