RDLC报告仅在页面加载时加载,但不加载按钮单击事件

时间:2022-11-28 21:01:00

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;

我是asp.net编程的新手,我想在每次单击按钮时在reportviewer中加载rdlc报告。如果我在页面加载时调用LoadReport函数,问题是报告正确加载但是当我在按钮点击时加载报告时出现问题。它显示没有错误。我创建了DataSet1.xsd并将其附加到rdlc报告,在另一个aspx页面中我填充了DataSet1.xsd并附加到ReportDataSource()。它显示了数字列和数据,它得到了绑定没有错误的报告,但每当我看到aspx页面它总是空白。请提供解决方案,因为它是我的首要任务。这是我的代码;

 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 个解决方案

#1


0  

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....

它对我有用,希望它对你有用....

#1


0  

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....

它对我有用,希望它对你有用....