Reportviewer打印按钮未显示 [英] Reportviewer print button not showing

查看:112
本文介绍了Reportviewer打印按钮未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计模式下可以看到打印图标,但是在运行模式下看不到.

请参阅此代码,并给我一些解决方案. IE中也不会显示打印"图标.

I can see the print icon in the design mode, but I can''t see in the run mode.

Please see this code and give me some solution. Print icon is not showing in IE also.

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

        <rsweb:ReportViewer ID="ReportViewer1"  runat="server" Width="100%" SizeToReportContent="True" Height="800px" ProcessingMode="Remote">



按钮单击事件
===================



Button Click Event
====================

ReportViewer1.ProcessingMode = ProcessingMode.Local; 
LocalReport rep = ReportViewer1.LocalReport;  

rep.ReportPath = "Reports/Test.rdlc";
ReportDataSource dsStatus = new ReportDataSource("DataSet1_test_Report", Test_Report());

rep.DataSources.Clear();
rep.DataSources.Add(dsStatus);
rep.Refresh();

推荐答案

在crystalreportviewer中设置Showprintbutton=true

如果是Asp.net set hasprintbutton=true
set Showprintbutton=true in crystalreportviewer

in case of Asp.net set hasprintbutton=true




您必须在面板控件上添加自己的按钮并使用它们.我已经尝试过水晶报告.使用ReportViewer,您可以遍历页面,将报告直接打印到打印机.通常,打印图标和其他图标是可见的,但它们在客户端不起作用.
Hi,

You''ll have to add your own buttons on panel control and use them. I have tried with crystal report. Using the ReportViewer you can traverse through the pages, print the report directly to printer. Generally the print and other icons are visible, but they don''t work at the client side.


显示报告的面板.

The panel which shows the report.

<asp:Panel ID="panReport" runat="server" CssClass="panelReport" Visible="false">
    <table style="border-collapse:collapse; width:400px;" cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td class="printtd"><asp:Button id="btPrintRep" CssClass="btprint" ToolTip="Print Report" Text="Print" runat="server" /></td>
            <td class="printtd" style="width:20px;"><asp:Button ID="btFirstPage" ToolTip="First Page" Text="<<" CssClass="btprint" runat="server" /></td>
            <td class="printtd" style="width:20px;"><asp:Button ID="btNextPage" ToolTip="Next Page" Text=">" CssClass="btprint" runat="server" /></td>
            <td class="printtd" style="width:20px;"><asp:Button ID="btPrevPage" ToolTip="Previous Page" Text="<" CssClass="btprint" runat="server" /></td>
            <td class="printtd" style="width:20px;"><asp:Button ID="btLastPage" ToolTip="Last Page" Text=">>" CssClass="btprint" runat="server" /></td>
            <td class="printtd"><asp:Button ID="btCloseRep" ToolTip="Close" Text="Close" CssClass="btprint" runat="server" /></td>
        </tr>
    </table>
</asp:Panel>




后面的代码

将其写在模块中




Code behind

Write this in a module

Public Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    Public CrystalReportViewer As CrystalDecisions.Web.CrystalReportViewer = New CrystalDecisions.Web.CrystalReportViewer







Protected Sub btCloseRep_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btCloseRep.Click
        panReport.Visible = False
    End Sub

    Protected Sub btPrintRep_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btPrintRep.Click
        ' PRINT.
        If IsPostBack Then
            Report.PrintToPrinter(1, True, 0, 0)
            panReport.Visible = False
        End If
    End Sub

    Protected Sub btFirstPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btFirstPage.Click
        ShowReport(AnySqlQuery, "Report.rpt", "Report.xsd", "MyReport", panReport, SomeParameter)
        CrystalReportViewer.ShowFirstPage()
    End Sub

    Protected Sub btNextPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btNextPage.Click
        ShowReport(AnySqlQuery, "Report.rpt", "Report.xsd", "MyReport", panReport, SomeParameter)
        CrystalReportViewer.ShowNextPage()
    End Sub

    Protected Sub btPrevPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btPrevPage.Click
        ShowReport(AnySqlQuery, "Report.rpt", "Report.xsd", "MyReport", panReport, SomeParameter)
        CrystalReportViewer.ShowPreviousPage()
    End Sub

    Protected Sub btLastPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btLastPage.Click
        ShowReport(AnySqlQuery, "Report.rpt", "Report.xsd", "MyReport", panReport, SomeParameter)
        CrystalReportViewer.ShowLastPage()
    End Sub




''显示报告.




'' SHOW REPORT.

Private Function ShowReport(ByVal sQuery As String, ByVal rptFileName As String, ByVal xsdFileName As String, ByVal sTableName As String, _
                               ByRef panReport As Panel, ByVal sParameter As String) As Boolean
        Try

            If Trim(gS_UserFullName) <> "" Then
                Dim objDataAdapter As New System.Data.SqlClient.SqlDataAdapter(sQuery, myConn)
                Dim objDataSet As New DataSet
                objDataAdapter.SelectCommand.CommandTimeout = 500
                objDataAdapter.Fill(objDataSet, sTableName)

                ' CREATE THE XML FILE IN THE BASE DIRECTORY AND LOAD THE REPORT.
                objDataSet.WriteXmlSchema(System.AppDomain.CurrentDomain.BaseDirectory() & "reports\" & xsdFileName)
                Report.Load(System.AppDomain.CurrentDomain.BaseDirectory() & "reports\" & rptFileName & "")
                Report.SetDataSource(objDataSet)                                ' SET REPORT DATA SOURCE.

                ' PASS PARAMETERS.
                Report.Refresh()
                Report.SetParameterValue("RepHeader", sReportHeader)  

                CrystalReportViewer.BorderStyle = BorderStyle.None
                CrystalReportViewer.DisplayGroupTree = False : CrystalReportViewer.DisplayToolbar = False
                CrystalReportViewer.Zoom(150)
                CrystalReportViewer.BestFitPage = False : CrystalReportViewer.HasCrystalLogo = False
                CrystalReportViewer.Width = "1180" : CrystalReportViewer.Height = "770"
                CrystalReportViewer.ReportSource = Report

                panReport.Controls.Add(CrystalReportViewer)                     ' ADD THE VIEWER WITH A PANEL CONTROL ON THE PAGE.
                panReport.Visible = True

                ShowReport = True
            End If
        Catch ex As Exception
            ShowReport = False
        Finally

        End Try
    End Function


这篇关于Reportviewer打印按钮未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆