62,046
社区成员
发帖
与我相关
我的任务
分享
public static void SpanSingleRow(GridView gView, int GroupColumn, int Compare1)
{
int i = 0;
int j = 0;
int rowSpan;
string strSource = "";
string strTarget = "";
for (i = 0; i < gView.Rows.Count; i++)
{
rowSpan = 1;
strSource = gView.Rows[i].Cells[Compare1].Text;
for (j = i + 1; j < gView.Rows.Count; j++)
{
strTarget = gView.Rows[j].Cells[Compare1].Text;
if (strSource.Length > 0 && strSource != " " && string.Compare(strSource, strTarget) == 0)
{
rowSpan += 1;
gView.Rows[i].Cells[GroupColumn].RowSpan = rowSpan;
gView.Rows[j].Cells[GroupColumn].Visible = false;
}
else
{
break;
}
}
i = j - 1;
}
}