gridview 跨行 跨列(原创)

recordid unitname unittype note
1 1  
10 4  
100 4  
101 请录入名称 0 请录入备注
102 0 请录入备注
103 0
104 0 请录入备注
11 4  
12 4  
13


    protected void gvTest_DataBound(object sender, EventArgs e)
    {
        gvTest.Rows[3].Cells[1].RowSpan = 4;   //请录入名称 跨4行
        for (int i = 4; i < 7; i++)
        {
            gvTest.Rows[i].Cells.RemoveAt(1);
        }

        gvTest.Rows[9].Cells[1].ColumnSpan = 3; //罐 跨3列
        for (int i = 3; i < 5; i++)
        {
            gvTest.Rows[9].Cells.RemoveAt(2);
        }

        gvTest.Rows[5].Cells[1].ColumnSpan = 2;  //0 跨2列
        for (int i = 4; i < 5; i++)
        {
            gvTest.Rows[5].Cells.RemoveAt(2);
        }
    }
}

原文地址:https://www.cnblogs.com/pchgo/p/1273073.html