Click here to Skip to main content
15,917,964 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datatable like below

name   Subjects     mark
----   --------     -----
Nim    Chemistry     23
Nim    Physics       24
Nim    Maths         25


I want to bind this datatable to a gridview like below

Name        Chemistry    Physics    Maths  
------      ---------   --------    -----
Nim            23         24         25
Posted
Updated 14-Aug-12 1:36am
v2
Comments
AmitGajjar 14-Aug-12 7:53am    
didn't get you. please elaborate

Use SQL Server PIVOT

Dynamic Pivoting in SQL Server[^]
 
Share this answer
 
Just create a local data table with columns as
Column1 - Name
Column2 - Chemistry
Column3 - Physics
Column4 - Maths

Add rows to these data table and say gridview.datasource = data table name
 
Share this answer
 
Comments
Nimisha Mary John 14-Aug-12 7:59am    
Actually some times the subject s more than shown

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