Visual Studio .NET - ReportViewer does not show Print option.
Asked By imran khan
10-Mar-07 04:27 AM
Dear all,
I am making Asp.net , C#(Visual Studio 2005) and SQl2000.
I am trying to generate report using reportviewer. i managed to success in generating report but problewm is reportviewer does not show print option. by defualt printoption is set to true i also set in design that option true as
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
Height="400px" Style="left: 25px; position: absolute; top: 86px" Visible="False"
Width="862px" ShowPrintButton ="true" ShowBackButton="True" ShowFindControls="False">
<LocalReport ReportPath="Report.rdlc">
Still reportviewer does not show print option.
please help
Thanks
local reports
looks like you are running in local mode, e.g., local reports. You have to be running remote reports for the reportviewer's print button to work.
as mentioned in the below link,
http://forums.asp.net/thread/1490236.aspx
ReportViewer show Print option.(via Coding)

Hi Friends,
Your can't Show the print option in asp.net ReportViewer. We Can Access the print through Coding only. See the below Coding you can easy to access the print button.
First you put one button in your print page ie(put top of the report viewer page)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim myRPTForm As New RdlGenerator ' This would be your rdlc report for your labels
Dim report As LocalReport = New LocalReport()
' Public myPRT As Reporting
Dim myPRT As New Reporting
Dim m_rdl2 As System.IO.Stream
m_rdl2 =
New System.IO.FileStream("D:\Reports\SampleHead1.rdl", IO.FileMode.Open, IO.FileAccess.Read)
' Set the physical path to your report rdlc file.
report.LoadReportDefinition(m_rdl2)
' report.ReportPath = "C:\data\reports\ActReq.rdlc"
' This next code binds my datasource to my report. I suspect you may be handling this differently.
Dim da5 As New SqlClient.SqlDataAdapter("select * from dbo.COLUMN_VALUE_VIEW", "Persist Security Info=False;User ID=;pwd=; Initial Catalog=; Data Source=")
da5.Fill(m_dataSet4)
report.DataSources.Add(
New ReportDataSource("DataSet1", m_dataSet4.Tables(0)))
' This next code prepares the rdlc file for printing and calls the print function from the Reporting class file
myPRT.Export(report)
myPRT.m_currentPageIndex = 0
myPRT.Print()
End
Sub
AFTER That Create one class file like "Reporting.vb"
Imports
System.IO
Imports
System.Data
Imports
System.Text
Imports
System.Drawing.Imaging
Imports
System.Drawing.Printing
Imports
System.Collections.Generic
Imports
Microsoft.Reporting.WinForms
Public
Class Reporting
Implements IDisposable
Public m_currentPageIndex As Integer
Public m_streams As IList(Of Stream)
Public Function CreateStream(ByVal name As String, _
ByVal fileNameExtension As String, _
ByVal encoding As Encoding, ByVal mimeType As String, _
ByVal willSeek As Boolean) As Stream
Dim stream As Stream = _
New FileStream("D:\" + name + "." + fileNameExtension, FileMode.Create)
m_streams.Add(stream)
Return stream
End Function
Public Sub Export(ByVal report As LocalReport)
Try
Dim deviceInfo As String = _
"<DeviceInfo>" + _
" <OutputFormat>EMF</OutputFormat>" + _
" <PageWidth>8.5in</PageWidth>" + _
" <PageHeight>11in</PageHeight>" + _
" <MarginTop>0.25in</MarginTop>" + _
" <MarginLeft>0.25in</MarginLeft>" + _
" <MarginRight>0.25in</MarginRight>" + _
" <MarginBottom>0.25in</MarginBottom>" + _
"</DeviceInfo>"
Dim warnings() As Warning = Nothing
m_streams =
New List(Of Stream)()
report.Render(
"Image", deviceInfo, AddressOf CreateStream, warnings)
Dim stream As Stream
For Each stream In m_streams
stream.Position = 0
Next
Catch ex As Exception
End Try
End Sub
Public Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim pageImage As New Metafile(m_streams(m_currentPageIndex))
ev.Graphics.DrawImage(pageImage, ev.PageBounds)
m_currentPageIndex += 1
ev.HasMorePages = (m_currentPageIndex < m_streams.Count)
End Sub
Public Sub Print()
Const printerName As String = "Microsoft Office Document Image Writer"
If m_streams Is Nothing OrElse m_streams.Count = 0 Then
Return
End If
Dim printDoc As New PrintDocument()
' printDoc.PrinterSettings..PrinterName = printerName
If Not printDoc.PrinterSettings.IsValid Then
Dim msg As String = String.Format( _
"Can't find printer ""{0}"".", printerName)
Console.WriteLine(msg)
Return
End If
AddHandler printDoc.PrintPage, AddressOf PrintPage
printDoc.PrinterSettings.Duplex = Duplex.Horizontal
printDoc.Print()
End Sub
Public Overloads Sub Dispose() Implements IDisposable.Dispose
If Not (m_streams Is Nothing) Then
Dim stream As Stream
For Each stream In m_streams
stream.Close()
Next
m_streams =
Nothing
End If
End Sub
End
Class
Compile and Check it..
Regards,
K. Raja
raja_online@hotmail.com

Frequently asked Interview Questions in ADO.Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B)What is a B) What is concept of Boxing and Unboxing ? (B) What is the difference between VB.NET and C#? (I) what is the difference between System exceptions and Application exceptions? (I)What is CODE Access security? (I)What is a satellite assembly? (A) How to prevent my .NET DLL to be decompiled? (I) what is the difference between Convert.toString and .toString () method
Interview Questions for .NET Framework This article is specially for the users those are in development or want to be a .net developer • To test a Web Service you must create a windows application or web application to consume this service? It is True / False? FALSE How many classes can a single.NET DLL contain? Answer1: As many Answer2: One or more What are good ADO.NET object(s) to replace the ADO Recordset object? The differences includes In ADO, the in memory representation of data is the recordset. In ADO.net, it is the dataset A recordset looks like a single table in ADO In contrast, a dataset is a collection of one or more tables in ADO.net ADO is designed primarily for connected access ADO net the disconnected access to the database is used In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter
visual studio installation problem Actually, my OS is Windows Xp with service pack2.I added service pack3 to install visual studio2010.after that i tryed to installed, but am getting SETUP FAILED due to "Windows XP is not installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual F# 2.0 Runtime was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio Macro Tools was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates .NET Framework 4 Multi-Targeting Pack was not attempted to be installed. [08 / 10 / 11, 14:26:01] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Professional - ENU was not attempted to be installed. [08 / 10 / 11, 14:26
on my Win XP SP 1 system that was later upgraded to SP2 and has .NET Framework 1.1 installed. I get an error message that says "Setup could not copy help. I would greatly appreciate it. Thanks, George - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - see below for IIS6.log - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - [3 / 5 / 2005 12:57:45] LogFile Open. [* ** ** Search on FAIL / MessageBox keywords for failures * ** **]. [3 / 5 / 2005 12:57:45] Initial thread locale = 409 [3 / 5 / 2005 12:57:45] returned from France fix with locale 409 [3 / 5 2005 12:57:45] OC_PREINITIALIZE:[iis] End. Return = 1 (OCFLAG_UNICODE) [3 / 5 / 2005 12:57:45] OC_INIT_COMPONENT:[iis, (null)] Start. [3 / 5 / 2005 12:57:45] OC_INIT_COMPONENT:3 / 31 / 2003 12:00:00 A_ __ __ __ 6.0.2600.2180 0.2600.2180 (xpsp_sp2_rtm.040803-2158): x86: C: \ WINDOWS \ system32 \ Setup \ iis.dll [3 / 5 / 2005 12:57:45] OC_INIT_COMPONENT:Set UnAttendFlag:OFF (File = '') [3 / 5 / 2005 12:57:45] OC_INIT_COMPONENT
choosen the Blog post from here This means the installation should be on a single server as Domain Controller , as MS SQL database server and as MOSS2007 server farm. Only one uses should be used. Thats what I have done, I followed the I am reading the logfiles placed under "c: \ program files \ common files \ microsoft shared \ web server extensions \ 12 \ logs". I don't find any relavant information regarding authentication or what else von der Anmeldung angeforderte 'SharePoint_07_Config'-Datenbank kann nicht geöffnet werden. Fehler bei der Anmeldung.' Source: '.Net SqlClient Data Provider' Number: 4060 State: 1 Class: 11 Procedure: '' LineNumber: 65536 Server: 'd-it5-sptest-dc' 03 / 04 / 2010 13:53:11.35 OWSTIMER.EXE (0x0980) 0x0988 Services Database 880j High SqlError: 'Fehler bei der Anmeldung für den Benutzer 'SPTEST \ spadmin'.' Source: '.Net SqlClient Data Provider' Number: 18456 State: 1 Class: 14 Procedure: '' LineNumber: 65536 Server: 'd-it5