Verwendung von Rowspan in Gridview nur für die 1. Spalte

Benötigen Sie Hilfe, um ein Problem im Zusammenhang mit dem Gridview-Layout zu beheben. Ich versuche, Custome Gridview mit Itemtemplate Columns mithilfe der C # .Net-Sprache zu implementieren, und möchte View mithilfe der RowSpan-Eigenschaft einschließen.

Ich habe versucht, den folgenden Code zu verwenden, aber es hat bei mir nicht funktioniertHier

Bitte überprüfen Sie den Code, den ich verwendet habe:

 protected void GridView31_DataBound1(object sender, EventArgs e)
{
    for (int rowIndex = grdView31.Rows.Count - 2; rowIndex >= 0; rowIndex--)
    {
        GridViewRow gvRow = grdView31.Rows[rowIndex];
        GridViewRow gvPreviousRow = grdView31.Rows[rowIndex + 1];
        for (int cellCount = 0; 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;
            }
        }
    }

}

Aber jedes Mal diegvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text ist leer.

Daher nimmt das Gitter seltsame Formen an. Ich weiß nicht, was hier passiert.

Kann jemand helfen?

Antworten auf die Frage(3)

Ihre Antwort auf die Frage