需要帮助解决与Gridview布局相关的问题。我正在尝试使用C#.Net语言实现自定义Gridview,使用Itemtemplate列并想要使用RowSpan属性包含视图。
我尝试使用以下代码,但对我无效 这里
请检查我使用的代码:
但每次
因此,网格会呈现奇怪的形状。不知道这里发生了什么。
有人能帮忙吗?
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;
}
}
}
}
但每次
gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text
为空。因此,网格会呈现奇怪的形状。不知道这里发生了什么。
有人能帮忙吗?