locked
sending rdlc report to other page RRS feed

  • Question

  • User1465791785 posted

    i want to send report genereated genereated in the report viewer to another page

    from the code i have written , the page is a blank and it doesnt display the report generated in the report viewer

    using System;
    using System.IO;
    using System.Data;
    using System.Text;
    using System.Drawing.Imaging;
    using System.Drawing.Printing;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    using Microsoft.Reporting.WebForms;
    
    public partial class PortActivites : System.Web.UI.Page
    {
        public string con =
            ConfigurationManager.ConnectionStrings[
            "ConectionString"].ConnectionString;
    
    
        protected void Page_Load(object sender, EventArgs e)
        {
    
    
        }
    
    
    
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
    
            ReportViewer1.Visible = true;
            SqlConnection thisConnection = new SqlConnection(con);
            SqlCommand com = new SqlCommand("ActvitiesFinal", thisConnection);
            com.CommandType = CommandType.StoredProcedure;
            com.Parameters.AddWithValue("@chkDate", txtStartDate.Text);
            com.Parameters.AddWithValue("@EndDate", txtEndDate.Text);
    
    
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = com;
    
            DataSet ds = new DataSet();
    
            thisConnection.Open();
            da.Fill(ds);
    
    
    
    
    
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));
            ReportParameter Sdate = new ReportParameter("StartDate", txtStartDate.Text);
            ReportParameter Edate = new ReportParameter("EndDate", txtEndDate.Text);
            //ReportParameter EYear = new ReportParameter("Year", txtStartDate.Text.ToString("yyyy",Culture
            ReportViewer1.LocalReport.SetParameters(Sdate);
            ReportViewer1.LocalReport.SetParameters(Edate);
    
    
    
            if (ds.Tables[0].Rows.Count == 0)
            {
    
                lblMessage.Text = "Sorry,there isnt";
            }
    
            else
            {
                Response.Redirect("Default2.aspx");
            }
    
            ReportViewer1.LocalReport.Refresh();
      
        }
    
    
    
    }
        <table class="auto-style1">
            <tr>
                <td colspan="2">Port Activities</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style2">Date From</td>
                <td class="auto-style3">
                    <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
                </td>
                <td>Date To<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style2">
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
                </td>
                <td class="auto-style3">
                    <asp:Label ID="lblMessage" runat="server" Visible="False"></asp:Label>
                </td>
                <td>
                    <asp:Button ID="PrintButton" Text="Print" runat="server"  OnClientClick="return PrintPanel();" />
                </td>
            </tr>
        </table>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
    
    
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="895px" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
            <LocalReport ReportPath="Reports\DepartureReport.rdlc" EnableHyperlinks="True">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="DataSet1" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConectionString %>" SelectCommand="ActvitiesFinal" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter Name="chkDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="Datetime" />
    
            </SelectParameters>
        </asp:SqlDataSource>



    Wednesday, July 16, 2014 2:10 AM