Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
In c# asp.net , how to display multiple row data from database in to a single row in gridview and same to view in crystal report



eg:

Output which i want it to be:

StaffName | Role | GroupNumber
Adrian | Lecturer | 1,2

Instead of:

StaffName | Role | GroupNumber
Adrian | Lecturer | 1
Adrian | Lecturer | 2
Posted
Updated 11-Nov-13 22:23pm
v2
Comments
TrushnaK 12-Nov-13 5:21am    
write your query with group by clause with groupNumber column. Then assign result to gridview.

1 solution

You Can refer this query to solve your problem.It is working ...
SQL
SELECT Employee_City, STUFF((SELECT Employee_Name AS A FROM EmployeeMaster AS tab2 WHERE       
 (Employee_City = tab1.Employee_City) FOR XML PATH('')), 1, 2, '') AS Employee_Name
FROM  EmployeeMaster AS tab1
GROUP BY Employee_City
 
Share this answer
 
v2

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