what database are you using? 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 can I ask the question as why do you want to do this?