VB.Net Report查看器参数

时间:2015-01-06 19:58:26

标签: vb.net parameters filter report reportviewer

我在report.rdlc中添加了一个名为" ReportTitle"的参数。它是文本并允许空值和空值。我尝试过不同的方法来传递参数值无济于事。这是我到目前为止所尝试的:

  Dim parReportParam1 As New ReportParameter("ReportTitle", "THIS IS MY TITLE")
  ReportViewer1.LocalReport.SetParameters(New ReportParameter() {parReportParam1})

不起作用!

    Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
    params(0) = New Microsoft.Reporting.WinForms.ReportParameter("ReportTitle", "THIS IS MY TITLE")
    ReportViewer1.LocalReport.SetParameters(params)

没有!

    Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
    params(0) = New Microsoft.Reporting.WinForms.ReportParameter
    params(0).Name = "ReportTitle"
    params(0).Values.Add("THIS IS MY TITLE")
    ReportViewer1.LocalReport.SetParameters(params)

都能跟得上!

我不知道该怎么办。我是否必须在reportviewer或设计器上设置一些内容以允许参数值。非常感谢任何帮助。

5 个答案:

答案 0 :(得分:0)

这对我有用:

    Dim paramStoreNo As New ReportParameter("StoreNo", iSTORE_NO)
    Dim reportparameters() As ReportParameter = {paramStoreNo}
    InventoryTableAdapter.Fill(Me.DataSet1.Inventory, iSTORE_NO)
    Me.ReportViewer1.LocalReport.SetParameters(reportparameters)
    Me.ReportViewer1.RefreshReport()

答案 1 :(得分:0)

可能您不小心将参数的可用值设置为public class EmployeeTreeModel implements TreeViewModel { private final List<Team> teamList; private final SingleSelectionModel<Employee> selectionModel = new SingleSelectionModel<Employee>(); public EmployeeTreeModel() { teamList = new ArrayList<Team>(); { for (int i = 0; i < 5 ; i++) { teamList.add(new Team(i) ); } } } @Override public <T> NodeInfo<?> getNodeInfo(T value) { if (value == null) { ListDataProvider<Team> dataProvider = new ListDataProvider<Team>(teamList); Cell<Team> cell = new AbstractCell<Team>() { @Override public void render(Context context, Team value, SafeHtmlBuilder sb) { if (value != null) { sb.appendHtmlConstant(" "); sb.appendEscaped(value.getNom()); } } }; return new DefaultNodeInfo<Team>(dataProvider, cell); } else if (value instanceof Team) { ListDataProvider<Employee> dataProvider = new ListDataProvider<Employee>( ((Team) value).getMembers()); Cell<Employee> cell = new AbstractCell<Employee>() { @Override public void render(Context context, Employee employee, SafeHtmlBuilder sb) { if (employee != null) { sb.appendHtmlConstant(" "); sb.appendEscaped(employee.getNom()); } } }; return new DefaultNodeInfo<Employee>(dataProvider, cell,selectionModel, null); } return null; } @Override public boolean isLeaf(Object o) { if (o instanceof Employee) { return true; }else if(o instanceof Person){ return true; } else return false; } } null中的其他值。如果是这样,请转到参数属性并将report.rdlc设置为Available Values,然后重试。

答案 2 :(得分:0)

如果问题是您无法在报告中看到参数值,可以尝试在报告查看器代码页中添加刷新。

在代码末尾添加此内容

Reportviewer.localreport.refresh()

问题可能是因为在应用程序完成传递值之前加载了页面,所以刷新它以便可以使用手头的参数值重新加载。

答案 3 :(得分:0)

我找到了Aswer,你需要记住在选择前所未有的报告路径之后输入参数。

我有同样的问题,一切都很好,直到我把参数输入Raport并且我花了两个小时才找到原因。

答案 4 :(得分:0)

我使用了以下代码并且工作正常:

For Each param As WinForms.ReportParameterInfo In ReportViewer1.LocalReport.GetParameters()


If param.name = "ReportTitle" Then

 ReportViewer1.LocalReport.SetParameters(New WinForms.ReportParameter(param.Name, "THIS IS MY TITLE"))

End If

Next

Me.ReportViewer1.RefreshReport()