Most efficient way to display a DataGrid with horizontal columns.
Posted on 2005-03-10
I'm looking for a solution that is as elegant as the DataGrid, but allows me to display columns horizontally. I want to be able to take a query like:
"SELECT Name, Address, PhoneNumber FROM myTable WHERE id = 1"
...and display this table:
Name: John Doe
Address: 123 Eisenhower Rd.
Normally, the DataGrid would display the column headers at the top instead of the left, like so:
Name Address PhoneNumber
John Doe 123 Eisenhower Rd. 555-1212
Is there an elegant way to do this without using a repeater or something similar? I have several dynamic recordsets, so I don't want to specify the column headers. I just want it to take the record set, bind to the DataGrid, and AutoGenerateColumns on the left instead of the top. A special server control, perhaps? I know I could create a asp:Table and dynamically create the columns and values, but I was hoping for something simpler.