人名 5/27 5/28
张力 vvv...... test......
张力 null null
张力 mm...... xzczc......
刘佳 null null
张军 sdfd...... null
张军 null null
2,合并后
人名 5/27 5/28
张力 vvv...... test......
null null
mm...... xzczc......
刘佳 null null
张军 sdfd...... null
null null
谢谢!
7 个解决方案
#1
不要沉啊!在线等!
#2
这种估计只能用"方法"的方式画表格来实现吧?
GridView跨行好像不行
GridView跨行好像不行
#3
对数据进行合并,然后再填充到GRIDVIEW中,不难。
#4
//用一个列来控制指定列的合并情况。
//调用方法:SpanSingleRow(gView,0,0);//合并第1列中相同的数据
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;
}
}
#5
//用一个列来控制指定列的合并情况。
//调用方法:SpanSingleRow(gView,0,0);//合并第1列中相同的数据
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;
}
}
#6
参考
http://www.cnblogs.com/ziyiFly/archive/2008/09/12/1283888.html
http://www.cnblogs.com/xjb/articles/1004203.html
http://www.cnblogs.com/ziyiFly/archive/2008/09/12/1283888.html
http://www.cnblogs.com/xjb/articles/1004203.html
#7
gView.Rows[i].Cells[GroupColumn].
RowSpan = rowSpan;
#1
不要沉啊!在线等!
#2
这种估计只能用"方法"的方式画表格来实现吧?
GridView跨行好像不行
GridView跨行好像不行
#3
对数据进行合并,然后再填充到GRIDVIEW中,不难。
#4
//用一个列来控制指定列的合并情况。
//调用方法:SpanSingleRow(gView,0,0);//合并第1列中相同的数据
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;
}
}
#5
//用一个列来控制指定列的合并情况。
//调用方法:SpanSingleRow(gView,0,0);//合并第1列中相同的数据
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;
}
}
#6
参考
http://www.cnblogs.com/ziyiFly/archive/2008/09/12/1283888.html
http://www.cnblogs.com/xjb/articles/1004203.html
http://www.cnblogs.com/ziyiFly/archive/2008/09/12/1283888.html
http://www.cnblogs.com/xjb/articles/1004203.html
#7
gView.Rows[i].Cells[GroupColumn].
RowSpan = rowSpan;