简易代码之家

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  157 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks
// 合并多行列值
        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 on 2014-10-09 15:10 Jakin.zhou 阅读(138) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: