GridView合并多行列值

// 合并多行列值
        public void GroupRows(GridView GridView1, int cellNum)
        
{
            
int i = 0, rowSpanNum = 1;
            
while (i < GridView1.Rows.Count - 1)
            
{
                GridViewRow gvr 
= GridView1.Rows[i];
                
for (++i; i < GridView1.Rows.Count; i++)
                
{
                    GridViewRow gvrNext 
= GridView1.Rows[i];
                    
if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
                    
{
                        gvrNext.Cells[cellNum].Visible 
= false;
                        rowSpanNum
++;
                    }

                    
else
                    
{
                        gvr.Cells[cellNum].RowSpan 
= rowSpanNum;
                        rowSpanNum 
= 1;
                        
break;
                    }

                    
if (i == GridView1.Rows.Count - 1)
                    
{
                        gvr.Cells[cellNum].RowSpan 
= rowSpanNum;
                    }

                }

            }

        }
posted @ 2014-10-09 15:10  Jakin.zhou  阅读(193)  评论(0编辑  收藏  举报