Swapping rows and columns in gridview

one option would be to use database functions to transform the data and then give directly to gridview
OR
use arrays to transform the data programmatically after fetching the records, and then give it to gridview