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

时间:2012-10-26 13:07:30

标签: c# asp.net rdlc dynamic-rdlc-generation

我是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 个答案:

答案 0 :(得分:0)

使用触发器.....

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

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