Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Most efficient way to display a DataGrid with horizontal columns.

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.
PhoneNumber:      555-1212

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.
0
hendridm
Asked:
hendridm
  • 2
1 Solution
 
raterusCommented:
This is going to be impossible with the datagrid, the whole concept of this control is that each datagrid row is mapped to each row in the datasource.  What you could do is "rotate" the result set, and bind it rotated, that may work.  You'll have to scrap any concept of headers/footer that the datagrid has, but it may work for you.  Other than that, you probably can use the asp:table object, and add rows dynamically.  It's just a very weird way to display data if you ask me...  Are you just displaying one row of the datasource or many rows?.  In asp.net 2.0 they are coming out with a "detailsview" control, meant to display one item of a datasource.
0
 
raterusCommented:
0
 
hendridmAuthor Commented:
Perfect!  Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now