amulett

amulett

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 string logo = "";
    
int i = 0;
    
int j = 0;
    
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        
if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[
1].ColumnSpan = 2;a
            e.Row.Cells[
2].Visible = false;
            
return;
        }
        
if (e.Row.RowType == DataControlRowType.DataRow)
        {
            
if (i == 0)
            {
                logo 
= e.Row.Cells[1].Text;
                i
++;
            }
            
else
            {
                
if (logo == e.Row.Cells[1].Text)
                {                   
                    j
++;
                }
                
else
                {
                    
this.GridView1.Rows[i - 1 - j].Cells[1].RowSpan = j + 1;
                    
for (int x = j; x > 0; x--)
                    {
                        
this.GridView1.Rows[i-x].Cells[1].Visible = false;
                    }

                    j 
= 0;
                    logo 
= e.Row.Cells[1].Text;
                }
                i
++;
            }            
        }
        
if (e.Row.RowType == DataControlRowType.Footer)
        {
            
this.GridView1.Rows[i - 1 - j].Cells[1].RowSpan = j + 1;
            
for (int x = j; x > 0; x--)
            {
                
this.GridView1.Rows[i - x].Cells[1].Visible = false;
            }

            j 
= 0;
            logo 
= e.Row.Cells[1].Text;
        }
        
    }

 

posted on 2009-01-05 21:51  amulett  阅读(719)  评论(0编辑  收藏  举报