Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i bind matrix data using any datatools like gridview,repeater etc.
My problem is,I have a sql-output like below(Using Query)

Monthid   month  head  amount
 6        june   DA    100
 6        june   TA    110
 6        june   HRA   330
 8        Aug    DA    210
 8        Aug    TA    620
 8        Aug    HRA   510
 1        jan    DA    250
 1        jan    TA    320
 1        jan    HRA   320


i want to display it in datacontrol like below

month  DA   TA   HRA

Jan    250  320  320
June   100  110  330
Aug    210  620  510
Posted
Updated 6-Aug-12 2:32am
v3

1 solution

try this actually i have not tested it but you will get logic.
SQL
select A.month ,
 (select B.amount where B.monthid=A.monthid and B.head='DA') as 'DA',
 (select B.amount where B.monthid=A.monthid and B.head='TA') as 'TA',
(select B.amount where B.monthid=A.monthid and B.head='HRA') as 'HRA'
from tablename A
inner join tablename  B on
A.monthid= b.monthid
 
Share this answer
 
Comments
Nimisha Mary John 6-Aug-12 0:41am    
Sorry friend,I dont want query,I need to bind the given 'firstform of output' in a datacontrol like 2nd format

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