Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
In database records as follows
 

Room Course
 
1 AFF
2 MFA
3 REO
4 SAC
5 MFA
6 PST
7 RM
8 MC
 
i want to display the record in datagridview as follows using c#
 
Room Course Room Course
 
1 AFF 5 MFA

2 MFA 6 PST
 
3 REO 7 RM
 
4 SAC 8 MC
 

Note it is windows application
 

Rgds,
Narasiman P
Posted 9-Jul-13 18:11pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

its not feasible to divide the records from dataset and bind it to the gridview, better divide it in the StoredProcedure as two columns and return it to the application and catch the data in a dataset and bind it to the gridview.

the stored procedure will be
 

select d.*
	into	#temp_tab
	from(
	select
			row_number() over(order by name) rno, User_Id,
			name,
			
	from	TableName a inner join
	
	select 
			a.User_ID ID,a.name NAME
	from
			(select row_number() over(order by name) new_rno ,* from #temp_tab where rno%2=1) a
			left outer join	(select row_number() over(order by name) new_rno ,* from #temp_tab where rno%2=0) 
			
	
	
	Drop table 	#temp_tab;	
 
 
it will divide the records into two colummns.
Hope it helps
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100