如何根据gridview中某列信息来合并单元格!!  请各位多指教啊~比如:如下所示
用户编号     用户名          Name         合计次数       单价       单价金额   合计金额  结款情况 
1           jake         搜狗输入法       120         5.0000    600       600       已结  
2            0001         搜狗输入法      100         0.00       0        0         未结     
2            0001          百度搜索        170         0.0000     0         0        未结      
3            0002         搜狗输入法       50          0.00       0        0         未结      
4            0003         搜狗输入法       70          0.0000     0        0         未结    
5             004          搜狗输入法       60          0.00        0        0        未结 
5               004             暴风影音         50          0.00        0        0       已结  
合并后的效果为用户编号     用户名          Name         合计次数       单价       单价金额   合计金额  结款情况 
1           jake         搜狗输入法       120         5.0000    600       600       已结  2            0001         搜狗输入法      100         0.00       0        0         未结     
                          百度搜索        170         0.0000     0         0        未结  
    
3            0002         搜狗输入法       50          0.00       0        0         未结 
     
4            0003         搜狗输入法       70          0.0000     0        0         未结 
   
5             004          搜狗输入法       60          0.00        0                
                           暴风影音         50          0.00        0        0       已结 
而不是说让只要是相同的就合并在一起!!!急急急......

解决方案 »

  1.   

        public static void GroupRows(GridView p_GridView, int[] p_ColumnsIndex)
            {
                int _Count = p_GridView.Rows.Count;
                string[] _TempText = new string[p_ColumnsIndex.Length];
                int[] _RowIndex =new int[p_ColumnsIndex.Length];
                for (int i = 0; i != _Count; i++)
                {
                    string _CellText = "";
                    for (int z = 0; z != p_ColumnsIndex.Length; z++)
                    {
                        _CellText += p_GridView.Rows[i].Cells[p_ColumnsIndex[z]].Text;
                        if (_TempText[z] == _CellText)
                        {
                            p_GridView.Rows[i].Cells[p_ColumnsIndex[z]].Visible = false;
                            p_GridView.Rows[_RowIndex[z]].Cells[p_ColumnsIndex[z]].RowSpan++;
                        }
                        else
                        {
                            _RowIndex[z] = i;
                            _TempText[z] = _CellText;
                            p_GridView.Rows[_RowIndex[z]].Cells[p_ColumnsIndex[z]].RowSpan = 1;
                        }
                    }
                }
            }
    看看行不使用GroupRows(GridView1, new int[]{0,1,2});