答案 0 :(得分:2)
您可以使用以下算法来完成工作:
/****************************************
* Grouping Algorithmus
* by Björn Karpenstein
* http://www.capri-soft.de/blog
****************************************/
// Nach dieser Spalte soll gruppiert werden
int k = 1;
// Für alle Zeilen (VON UNTEN NACH OBEN)
for (int i = GridView1.Rows.Count - 1; i > 0; i--)
{
GridViewRow row = GridView1.Rows[i];
GridViewRow previousRow = GridView1.Rows[i - 1];
// Für alle Spalten
for (int j = 0; j < row.Cells.Count; j++)
{
if ((row.Cells[k].Text == previousRow.Cells[k].Text) && (row.Cells[j].Text == previousRow.Cells[j].Text))
{
if (previousRow.Cells[j].RowSpan == 0)
{
if (row.Cells[j].RowSpan == 0)
{
previousRow.Cells[j].RowSpan += 2;
}
else
{
previousRow.Cells[j].RowSpan = row.Cells[j].RowSpan + 1;
}
row.Cells[j].Visible = false;
}
}
}
}
答案 1 :(得分:1)
您可以在RowDataBound事件中执行此操作。您必须记住 Locale locale =new Locale("pl");
ResourceBundle myResources = ResourceBundle.getBundle("MenuFactory_pl.properties",locale);
并且必须向后移除下一个单元格,因为下一行尚不存在。 rowspan
是包含需要比较的值的列。
row["myValue"]