RDLC Report loads only on page load but not button click event

2.6k Views Asked by At

I am new to the asp.net programming and i want to load the rdlc report in reportviewer whenever i click button.The problem is report is loaded correctly if i call LoadReport function on page load but problem happens when i load the report on button click.It shows no error.I have Created DataSet1.xsd and attached it to the rdlc report and in another aspx page i fill the the DataSet1.xsd and attached to ReportDataSource().It shows the number columns along with data and it gets bind to the report without error but whenever i see the aspx page it is always blank.Please provide me the solution as it is priority task for me. Here's my code;

 private void LoadReport()
    {
GetData();



            ReportViewer1.LocalReport.ReportPath = Server.MapPath("Reports/Report2.rdlc");
            ReportViewer1.ProcessingMode = ProcessingMode.Local;



            ReportDataSource rds = new ReportDataSource();
            rds.Name = "DataSet1";
            rds.Value = ds.DataTable1;          
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);
            ReportViewer1.DataBind();
            LocalizeReport(ReportViewer1.LocalReport);

            ReportViewer1.LocalReport.Refresh();
            ReportViewer1.Visible = true;
}

 private void GetData()
    {


            DataSet1.DataTable1Row dr = ds.DataTable1.NewDataTable1Row();

            dr[0] = "abc";
            dr[1] = "49/Male";
            dr[2] = "21656";
            dr[3] = " ";
            dr[4] = " ";
            dr[5] = " ";
            dr[6] = " ";
            dr[7] = " ";
            dr[8] = " ";
            dr[9] = " ";
            dr[10] = "abc";
            dr[11] = "ccvc";
            dr[12] = "abc";
            dr[13] = " ";
            dr[14] = " ";
            dr[15] = "abc ";
            dr[16] = " ";            
            ds.DataTable1.AcceptChanges();

            ds.DataTable1.AddDataTable1Row(dr);

        }

    }
1

There are 1 best solutions below

0
On

use triggers.....

enter code here <asp:UpdatePanel ID="Report_UP" runat="server">
    <ContentTemplate>
    </ContentTemplate>
     <Triggers> 
         <asp:PostBackTrigger ControlID="SubmitButton"/>        
     </Triggers>         
</asp:UpdatePanel>

it worked for me hope it works for u....