【发布时间】:2015-03-16 07:52:03
【问题描述】:
如何使用 c# 合并使用行网格视图,如 asp.net 中的图片
【问题讨论】:
-
这个问题你解决了吗?
如何使用 c# 合并使用行网格视图,如 asp.net 中的图片
【问题讨论】:
您可以通过 GridView 的RowSpan 轻松实现。
您可以参考以下链接
GridView: Creating groups and summaries
Implement GridView Grouping: Group similar GridView Rows in ASP.Net
Grouping Data in ASP.NET Gridview Control
希望对你有帮助:)
【讨论】:
for (int rowIndex = GridView1.Rows.Count - 2; rowIndex >= 0; rowIndex--)
{ GridViewRow gvRow = GridView1.Rows[rowIndex]; GridViewRow gvPreviousRow = GridView1.Rows[rowIndex + 1];
for (int cellCount = 1; cellCount < gvRow.Cells.Count; cellCount++)
{ if (gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text)
{ if (gvPreviousRow.Cells[cellCount].RowSpan < 2) { gvRow.Cells[cellCount].RowSpan = 2;
} else
{ gvRow.Cells[cellCount].RowSpan = gvPreviousRow.Cells[cellCount].RowSpan + 1; gvPreviousRow.Cells[cellCount].Visible = false; } } }
【讨论】: