Accessing the HTML5 WebForms ReportViewer from the code behind

0 Answers 334 Views
.NET Framework Report Parameters Report Viewer - HTML5 WebForms
Gail
Top achievements
Rank 1
Gail asked on 10 Feb 2022, 11:40 PM

Hello,

I am trying to use the HTML5 WebForms Report Viewer in an ASP.NET WebForms (.NET Framework 4.6.1) application.  I am using Telerik Reporting version 16.0.22.119.

I need to update the report source and parameters from the code behind, and I have not been able to get this to work. 

My report displays correctly when the page first loads.  Then, I select a choice from a drop-down list on the page.  I attempt to change the parameter and datasource in an event in the code behind.  When the screen refreshes, the report viewer is no longer there.

My report viewer is inside of an UpdatePanel on the page, like this:

			<asp:UpdatePanel ID="UP1" UpdateMode="Always" runat="server">
				<ContentTemplate>

					<%--practice group list and practice ddl--%>
					<div style="width: auto;">
						<uc:wucPracticeListAndPractice ID="PracticeAndListBar" runat="server"
						ControlStyle="Bar" AdjustWidths="True" SelectionsAreSticky="True"
						AllowAllPractices="false" />
					</div>

					<div style="border: 2px solid red;">

						<telerik:ReportViewer
							ID="reportViewer"
							Width="1300px"
							Height="900px"
							
							runat="server" ServiceUrl="https://localhost:44364/api/reports" >
							<ReportSource Identifier="Samples/TestReport.trdp" IdentifierType="UriReportSource">
								<Parameters>
									<telerik:Parameter Name="AccountOid" Value="00000000-0000-0000-0000-000000000000" />
								</Parameters>
							</ReportSource>
							
							<%-- If set to true shows the Send Mail Message toolbar button --%>
							<SendEmail Enabled = "false" />
						</telerik:ReportViewer>

						<telerik:DeferredScripts runat="server"></telerik:DeferredScripts>

					</div>

				</ContentTemplate>
			</asp:UpdatePanel>

In my event in the code behind:

            ReportSource reportSource = new ReportSource()
            {
                Identifier = "Samples/TestReport.trdp",
                IdentifierType = IdentifierType.UriReportSource
            };
            reportSource.Parameters.Add("AccountOid", Guid.Empty.ToString());

            this.reportViewer.ReportSource = reportSource;

Any suggestions on what I might be doing wrong?

Thank you.

Neli
Telerik team
commented on 15 Feb 2022, 01:07 PM

Hi Gail,

The provided code seems correct to me. I would suggest sending us a sample project that demonstrates the issue, so we can inspect it locally. You may find helpful the How to Pass Values to Report Parameters article.

No answers yet. Maybe you can help?

Tags
.NET Framework Report Parameters Report Viewer - HTML5 WebForms
Asked by
Gail
Top achievements
Rank 1
Share this question
or