locked
Problem in creating reports RRS feed

  • Question

  • User-1919429754 posted

    Hello,

    I created a report with the name "rptClient.rdlc". i created a dataset and designed the report fields. And this is my asp.net code to display the report,

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
            Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
            WaitMessageFont-Size="14pt">
            <LocalReport ReportPath="Admin\rptClient.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource Name="DataSet1" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

    And this is my c# code to set the datasource,

            public ReportDataSource rptSource;
    
            protected void Page_Load(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ToString());
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("select ClientID,FirstName,Surname from Client", con);
                DataSet ds = new DataSet("Client");
                da.Fill(ds, "Client");
    
                con.Close();
                con.Dispose();
    
                this.ReportViewer1.Reset();
                this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("rptClient.rdlc");
                rptSource = new ReportDataSource();
                rptSource.Name = "DataSet1";
                rptSource.Value = ds.Tables[0];
                this.ReportViewer1.LocalReport.DataSources.Clear();
                this.ReportViewer1.LocalReport.DataSources.Add(rptSource);
                this.ReportViewer1.DataBind();
                this.ReportViewer1.LocalReport.Refresh();
    
    
            }

    when i run the program the report is keep on loading. i could not get the result.

    Can anyone help me to solve this issue. if this is not the proper way of generating a report pleast let me know the method as well.

    thank you




    Wednesday, October 9, 2013 11:32 AM

Answers

  • User-417640953 posted

    this.ReportViewer1.LocalReport.Refresh();
    

    Hi prathap,

    Thanks for posting this issue to asp.net forum.

    According to your code, I see that you using the Refresh() method in page load event.

    Refresh() will generate a postback, and it will keep posting and posting.  Please add your code like below.

      if (!IsPostBack) 
      { 
         //your code....
       
      }

    If has any doubt, feel free to back. Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 13, 2013 11:29 AM

All replies

  • User-417640953 posted

    this.ReportViewer1.LocalReport.Refresh();
    

    Hi prathap,

    Thanks for posting this issue to asp.net forum.

    According to your code, I see that you using the Refresh() method in page load event.

    Refresh() will generate a postback, and it will keep posting and posting.  Please add your code like below.

      if (!IsPostBack) 
      { 
         //your code....
       
      }

    If has any doubt, feel free to back. Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 13, 2013 11:29 AM
  • User-1919429754 posted

    Hi,

    Thank you very much. I changed the code according to your instructions, and it works fine now.

    thanks a lot.

    prathap

    Monday, October 14, 2013 8:10 AM