0

我有一个从存储过程加载的数据集。它有田野。

DisplayID INT,
Display VARCHAR(45),
Default BIT

我有一个名为 DisplayFields 的参数,它是一个多值参数。对于可用值,我将 ValueField 设置为DisplayID,将 Label 字段设置为Display字段。

我希望默认选择是数据集中Default = 1的每条记录。有谁知道如何做到这一点?

编辑 1

我有一个存储过程。我用来填充数据集的。我添加了第二个数据集,其中包含基于默认字段的过滤器。我不喜欢这个解决方案,因为我相信我会调用该存储过程两次。

4

1 回答 1

1

If you always have at least one default value than you can implement such functionality as:

WITH TestData AS
(
    SELECT 0 AS ID, 'always default' AS Name, 1 AS IsDefaultValue
    UNION ALL
    SELECT 1 AS ID, 'test1' AS Name, 0 AS IsDefaultValue
    UNION ALL
    SELECT 2 AS ID, 'test2' AS Name, 1 AS IsDefaultValue
    UNION ALL
    SELECT 3 AS ID, 'test3' AS Name, 0 AS IsDefaultValue
    UNION ALL
    SELECT 4 AS ID, 'test4' AS Name, 1 AS IsDefaultValue
)
SELECT ID, 
       Name, 
       IsDefaultValue,
       CASE
            WHEN IsDefaultValue = 0
            THEN ID
            -- return id of always default value
            ELSE 0
       END AS DefaultID        
FROM TestData

Then in SSRS side you should add available value as ID and default as DefaultID. But we can't have in set of default values some value which isn't presented in set of available values (that's why we use "always default value"), in this case default selection won't work and you should call SP twice.

于 2012-12-18T17:00:19.380 回答