When I pass a parameter through, for use in the Select statement of a SQL Datasource, it gets passed as Null, even though it appears correctly when I set the parameter to visible (for testing).
The parameter is a Guid which I convert to a string before passing and then convert back to a Guid in the Select statement.
If I remove the Where clause in the Select statement, its fine.
I am using version 7.2.1.4.127 and have run the upgrade wizard. I have tried putting single quotes around the Guid.
I pass the parameter as follows:
Model
public TypeReportSource ReportSource
{
get
{
TypeReportSource reportSource = new TypeReportSource { TypeName = "AcumenSynergy.Reporting.PurchaseOrderLinesOutstanding, AcumenSynergy.Reporting"};
reportSource.Parameters.Add("ProjectID", this.SelectedProjectID.ToString());
return reportSource;
}
View
<div id="projectIDSelector">
@Html.LabelFor(model => model.SelectedProjectID)
@Html.DropDownListFor(model => model.SelectedProjectID, Model.ProjectItems, new { id = "projectID", title = "Select the Project" })
</div>
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl("/Reporting/api/Reports/")
.TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
.ReportSource(Model.ReportSource)
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(false)
)
<script>
$('#projectID').change(function () {
var viewer = $("#reportViewer1").data("telerik_ReportViewer");
viewer.reportSource({
report: viewer.reportSource().report,
parameters: { ProjectID: $(this).val() }
});
console.log($(this).val());
viewer.refreshReport();
});
</script>
Select Statement in SQL Data Source
Select * from dbo.Projects where ProjectID = (SELECT Convert(uniqueidentifier,@ProjectID))
The parameter is a Guid which I convert to a string before passing and then convert back to a Guid in the Select statement.
If I remove the Where clause in the Select statement, its fine.
I am using version 7.2.1.4.127 and have run the upgrade wizard. I have tried putting single quotes around the Guid.
I pass the parameter as follows:
Model
public TypeReportSource ReportSource
{
get
{
TypeReportSource reportSource = new TypeReportSource { TypeName = "AcumenSynergy.Reporting.PurchaseOrderLinesOutstanding, AcumenSynergy.Reporting"};
reportSource.Parameters.Add("ProjectID", this.SelectedProjectID.ToString());
return reportSource;
}
View
<div id="projectIDSelector">
@Html.LabelFor(model => model.SelectedProjectID)
@Html.DropDownListFor(model => model.SelectedProjectID, Model.ProjectItems, new { id = "projectID", title = "Select the Project" })
</div>
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl("/Reporting/api/Reports/")
.TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
.ReportSource(Model.ReportSource)
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(false)
)
<script>
$('#projectID').change(function () {
var viewer = $("#reportViewer1").data("telerik_ReportViewer");
viewer.reportSource({
report: viewer.reportSource().report,
parameters: { ProjectID: $(this).val() }
});
console.log($(this).val());
viewer.refreshReport();
});
</script>
Select Statement in SQL Data Source
Select * from dbo.Projects where ProjectID = (SELECT Convert(uniqueidentifier,@ProjectID))