Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2006-12-14 : 22:27:21
|
Dear Sir or MadamCan you help me? I have problem related to show header GridView in all pages when print or print preview.It's similar to crystal report that can show header on all pages.Now,I am using VS 2005 to build it but I don't know how to show header GridView in all pages of asp.net 2.0 when I print or print preview.I look forward to hearing from youThank you in advance!Good Luck and Succeed you work and study! seyha moth |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-15 : 00:45:10
|
You could try creating a report (add an item to your project and select Report as the item template). Then use the ReportViewer control (from the data tab) to display the report, the user can then print from the report viewer. It works very nicely - note that the ReportViewer control works with SQL Server Reporting Services server based reports, but does not require it, a report created in your web project runs in the viewer witout Reporting Services. |
 |
|
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2006-12-15 : 03:15:06
|
I'm creating cross tab report by using cross tab query with Store Procedure.I use ASP.NET 2.0 with Grid View to execute this store procedure.However,I print preview on asp.net web page but header row of grid view can not show on all pages,especially I am using window application to build to it.The following code is to create procedure to run cross tab queryALTER Procedure [dbo].[procX_ScoreResult]AS declare @EnSubjectName nvarchar(50)declare @Str nvarchar(4000)declare @Subject nvarchar(4000)declare subject_cursor CURSOR--FOR Select distinct EnSubjectName from vX_ScoreWithStudentInfo where AcademicYear='2006-2007' and Year='3' and Semester=2FOR Select distinct EnSubjectName from vX_ScoreWithStudentInfoOPEN subject_cursorset @Str=''set @Subject=''FETCH NEXT from subject_cursor into @EnSubjectNameWHILE @@FETCH_STATUS=0 BEGIN set @Str=@Str+'['+@EnSubjectName+']'+'=Sum(CASE WHEN EnSubjectName='''+@EnSubjectName+''' THEN Score END),' set @Subject=@Subject+'a1.['+@EnSubjectName+']'+',' FETCH NEXT FROM subject_cursor into @EnSubjectNameENDCLOSE subject_cursor--Remove (,) sign from the end of Stringset @Str=Substring(@Str,0,Len(@Str))set @Subject=SubString(@Subject,0,Len(@Subject))--Prepare Data to Cross tab Query then Create table called tblX_ResultExec('Select FullName,Sex,StudentID,'+ @Str +',CAST(Avg(Score) as Decimal(5,2)) as Average into tblX_Result From vX_ScoreWithStudentInfo Group by FullName,Sex,StudentID')--Find Rank Exec('SELECT a1.*, COUNT(a2.Average) RankFROM tblX_Result a1, tblX_Result a2 WHERE a1.Average < a2.Average or (a1.Average=a2.Average and a1.StudentID = a2.StudentID) GROUP BY a1.FullName,a1.StudentID,a1.Sex,a1.StudentID,a1.Average,'+@Subject+ ' ORDER BY Rank')Drop Table tblX_ResultDEALLOCATE subject_cursorI try test your posted comment but It make error There is an error in the query. Line 1: Incorrect syntax near ','.Incorrect syntax near the keyword 'ORDER'.I look forward to hearing from youThank you in advance!Good Luck and Succeed you work and study!seyha moth |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-15 : 11:06:58
|
What I am suggesting is that you don't use the GridView at all, rather create a report and display it with the ReportViewer. Reports allow you to create a matrix report which is a cross-tab report, so you won't need all that code to create the cross-tab. |
 |
|
|
|
|
|
|