[原]GridView一行显示多条数据

主要在    RowDataBound里处理

    protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                case DataControlRowType.Separator:
                    if (grv.Rows.Count == 0)
                        return;
                    if (e.Row.RowIndex % 3 != 0 && e.Row.RowIndex != 0)
                    {
                        int index = (int)(Math.Floor((double)e.Row.RowIndex / (double)3));
                        index = index * 3;
                        for (int i = 0; i < e.Row.Cells.Count; i++)
                            grv.Rows[index].Cells.AddAt(grv.Rows[index].Cells.Count,e.Row.Cells[i]);
                    }
                    break;
            }
        }

原文地址:https://www.cnblogs.com/xjyggd/p/1540644.html