Telerik Reporting无论用户是否选择如何强制“合同”选择

时间:2018-07-27 17:33:57

标签: telerik-reporting multivalue reportparameter

无论用户是否从下拉列表中选择,我都想强制返回参数“合同”。

enter image description here

1 个答案:

答案 0 :(得分:1)

您应该可以使用NeedDataSource事件。在此处查看其文档:https://docs.telerik.com/reporting/designing-reports-parameters-programmatic-control

特别注意此代码示例:

private void Report1_NeedDataSource(object sender, System.EventArgs e)
{
    //Take the Telerik.Reporting.Processing.Report instance
    Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;

    // Transfer the value of the processing instance of ReportParameter
    // to the parameter value of the sqlDataSource component
    // THIS IS WHERE YOU CAN FIND YOUR PARAMETER AND MODIFY ITS VALUE
    this.sqlDataSource1.Parameters[0].Value = report.Parameters["ManagerID"].Value;

    // Set the SqlDataSource component as it's DataSource
    report.DataSource = this.sqlDataSource1;
}

由于您的参数是多值,您将需要创建一个IEnumerable。然后,您可以将用户选择的参数的值添加到IEnumerable中。然后检查用户是否选择了"Contract",如果没有选择,则将其添加到列表中。最后,将IEnumerable添加到数据源的参数的value属性中。