Click here to Skip to main content
16,018,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Asp.net 4.0 and Sqlserver 2008. I want to fetch record from Database and display it into gridview.I am very new in this system(Freshers).I need it urgently.So please help me if anybody can.Thanks in Advance.

Table Structure :

CREATE TABLE dbo.DwlEntry
(
Id INT IDENTITY(1,1),
UserName VARCHAR(100),
ConfigItem VARCHAR(100),
Component VARCHAR(100),
TimeLogged DECIMAL(13,2)
)
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','AFOTA','Documentation','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','Troubleshooting','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','CodeChange','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','ProjectTraining','1')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','GENERAL','Troubleshooting','5')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','CodeChange','1')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','AFOTA','CodeChange','5')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','ProjectTraining','4')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','Documentation','2')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','GENERAL','ProjectTraining','4')

I want the Result in below way . Config item would be first row. and grouping come Horizontally like below Format

Config Item AFOTA AFOTA GENERAL GENERAL
User Name Documentation CodeChange ProjectTraining Troubleshooting Total
Bhanu 2 4 4 5 15
Bubai 3 5 5 3 16
Total 5 9 9 8 31
Posted
Updated 13-Feb-13 23:01pm
v2

1 solution

http://www.aspdotnet-suresh.com/2013/01/convert-gridview-columns-to-rows-in.html
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900