开发者

Group data in columns (instead of rows) in an HTML table using data bound control?

Is there a way to group data into columns using a data bound control in ASP.NET?

Normally, binding a control to an array of objects, I think of each object as a row. In a typical HTML table, the markup flows the same way and you get get something like this;

            HEADER1     HEADER2     HEADER3
Object1     Field1      Field2      Field3
Object2     Field1      Field2      Field3
Object3     Field1      Field2      Field3

What I want is this;

            Object1     Object2     Object3     
HEADER1     Field1      Field1      Field1
HEADER2     Field2      Field2      Field2
HEADER3     Field3      Field3      Field3

Outside of modifying the data so that each data item of the bound control holds all of Fiel开发者_如何学编程d1, then Field2, Field3, (instead of Object1, Object2, Object3,) I can't think of a way to do this.

Note, I am using .NET 2.0 and am stuck with those controls.

This is an extension of my question here where I wanted to float DIVs with each DIV reflecting an object.


Instead of rotating the control, how about rotating the data? I found this clever article on CodeProject that has a method to flip a DataSet on its axis: Vertical Rows in Datagrid

Here's a quick way to transpose an array:

public static void transpose(int[][] a, int[][] b, int width, int height){ 
  for (int i = 0; i < width; i++)
  {
    for (int j = 0; j < height; j++)
    {
      b[j][i] = a[i][j];
    }
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜