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;
// 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;
}
}