Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody,....

I stuck with an issue that i can popup the panel using ajax model pop up extender.. and there is a report viewer in that panel, problem is i can display a panel as popup, but it is not displaying a report which is in that panel.. i kept a break point for btnreport where i have written code to display report, but before executing the code in btnreport its displaying the popup.

my code is something like this...

VB
<asp:Button ID="btnreport" runat="server" Text="Report" OnClick="btnreport_Click"
                    CssClass="button" />

XML
<asp:Panel ID="pnlrept" runat="server" CssClass="modalPopup" Style="display: none;">
 <rsweb:ReportViewer ID="ReportViewer1" runat="server" ShowBackButton="true"> </rsweb:ReportViewer>
 <br />
<asp:Button ID="btnClose" runat="server" Text="Close" />
 </asp:Panel>
 <Murali:ModalPopupExtender ID="pnlrept_ModalPopupExtender" runat="server" DynamicServicePath="" Enabled="True" TargetControlID="btnreport" PopupControlID="pnlrept" CancelControlID="btnClose" DropShadow="True">
 </Murali:ModalPopupExtender>



and code in the button is..

C#
protected void btnreport_Click(object sender, EventArgs e)
    {
        BLL bl = new BLL();
        DataSet ds = bl.GetTrainingRecords(txtEmpId.Text);
        DataTable dt = new DataTable();
        dt = ds.Tables[0];
        string reportPath = @"D:\HRPortal\Training\Report.rdlc";
        ReportDataSource rds = new ReportDataSource
                ("TrainingRecord_TRdt", dt);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rds);
        ReportViewer1.LocalReport.ReportPath = reportPath;
        ReportViewer1.ZoomPercent = 100;
        ReportViewer1.LocalReport.Refresh();
    }

Can any help me please....

Thanks in advance.
Posted
Updated 12-Sep-12 19:29pm
v2

1 solution

Hi,

Normally, the script which will open the modal popup executes on client click of the button specified as the Target Control ID for the extender.

Here if you want to show the report as when the popup opens, then you can place the code which is in button click function, in some other place like Page Load or some other event which will occur before the user clicks on the button.

try like this.

C#
//Page Load event.
if(!IsPostBack)
{
    BLL bl = new BLL();
    DataSet ds = bl.GetTrainingRecords(txtEmpId.Text);
    DataTable dt = new DataTable();
    dt = ds.Tables[0];
    string reportPath = @"D:\HRPortal\Training\Report.rdlc";
    ReportDataSource rds = new ReportDataSource
            ("TrainingRecord_TRdt", dt);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(rds);
    ReportViewer1.LocalReport.ReportPath = reportPath;
    ReportViewer1.ZoomPercent = 100;
    ReportViewer1.LocalReport.Refresh();
}

and remove the post back and onclick event for button.

Hope it works.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900