This is a migrated thread and some comments may be shown as answers.

Report inside a RadGrid

4 Answers 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 06 Nov 2009, 07:04 PM
Hi support,

I was wondering if it was possible to place a report viewer inside a nested view template in a RadGrid.  When I did so, I set the report up and it didn't work.  The same report worked fine in the page load event of the same page, but on placing the reportviewer inside the nestedviewtemplate of a grid the report didn't work.

Thanks,
Josh

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 09 Nov 2009, 05:39 PM
Hello Josh,

How/where do you set the Report property of the viewer? You mention the Page_Load event - do you do that there and if so do you find the ReportViewer through FindControl and does that return correct object? If still having problems, a sample project that shows the issue would be appreciated.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Josh
Top achievements
Rank 1
answered on 09 Nov 2009, 06:51 PM
Support,

Sorry for the ambiguity, when I loaded the report in the page_load event I did not put the report viewer inside the hierarchical grid.  Rather, I placed the report viewer outside the grid and set the report property inside the page_load event just to see if the report itself was working properly. 

When I placed the report viewer inside the grid, I set the Report property in the ItemDataBound event.  First, I find the panel the report is contained in using the FindControl method. Second, I find the ReportViewer within that panel by using the FindControl method.  I then set the Report property to an instance of the Report class.  The correct object is returned.  However, when I set the value it doesn't display the report.  It displays the report viewer but the report is not loaded within it.

The question I have is:  Is this a problem with my code or is the ReportViewer not compatible with being inside the grid's nested view template?


See the below code:
    // Load event test  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!Page.IsPostBack)  
        {  
            Hello_World test = new Hello_World();  
 
            ReportViewerTest.Report = test;  
        }  
 
    }  
 
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridNestedViewItem)  
        {  
            System.Web.UI.WebControls.Panel panel = e.Item.FindControl("InnerContainer"as System.Web.UI.WebControls.Panel;  
            if (panel != null)  
            {  
                Telerik.ReportViewer.WebForms.ReportViewer reportViewer = panel.FindControl("ReportViewerMain"as Telerik.ReportViewer.WebForms.ReportViewer;  
                String claimLineKey = (panel.FindControl("myLabel"as Label).Text;  
 
                // create reporting instance  
                Hello_World batchReport = new Hello_World();  
 
                batchReport.ReportParameters["param1"].Value = claimLineKey;  
                reportViewer.Report = batchReport;  
                reportViewer.Style["Display"] = "block";  
                  
                  
            }  
        }  
    }  
 

Josh
0
Steve
Telerik team
answered on 12 Nov 2009, 04:51 PM
Hello Josh,

I have not been able to reproduce this in my test project which is attached to this thread for your convenience. Please review it and let us know what differs in your case.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Josh
Top achievements
Rank 1
answered on 12 Nov 2009, 04:59 PM
Steve,

I have solved my problem.  The report viewer must be set at the instant it is being loaded.  My above code was not doing that.
Here is the code I used to solve the problem in case anyone else runs into this.
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)  
    {  
        if (e.Item.OwnerTableView.Name == "ClaimLineAppPend" && e.CommandName == RadGrid.ExpandCollapseCommandName)  
        {  
            GridDataItem item = e.Item as GridDataItem;  
            GridNestedViewItem template = item.ChildItem;  
            RadMultiPage rmp = template.FindControl("Multipage1"as RadMultiPage;  
            ReportViewer viewer = rmp.FindControl("ReportViewerMain"as ReportViewer;  
            String claimLineKey = (rmp.FindControl("ClaimLineKey"as Label).Text;  
            //you have a reference to your report viewer now  
 
            // create reporting instance  
            Hello_World batchReport = new Hello_World();  
 
            batchReport.ReportParameters["pClaimLineKey"].Value = Convert.ToInt32(claimLineKey);  
            viewer.Report = batchReport;  
        }  
 
    } 

Regards,
Josh
Tags
General Discussions
Asked by
Josh
Top achievements
Rank 1
Answers by
Steve
Telerik team
Josh
Top achievements
Rank 1
Share this question
or