我有一个我正在使用的选择查询,它涉及网格视图显示的连接:
SELECT [Theme].[Name], [ThemeType].[Type]
FROM [Theme]
Left Outer Join [ThemeType] ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType]
ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 1 ELSE 0 END, [ThemeType].[Type]
这当前返回所有内容。我需要能够显示不返回空值或只返回空值,并且来自同一个查询,该查询将通过 SelectParameters 动态获取不同的输入。
基本上,我有一个包含 3 个选项的下拉列表,所有这些都在上面正确显示,但我需要一个选择参数来更改输入的值以产生 3 个选项。
我试过了:
SELECT [Theme].[Name], [ThemeType].[Type] FROM [Theme]
Left Outer Join [ThemeType] ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType]
WHERE [Theme].[ThemeTypeId] LIKE '%'
ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 1 ELSE 0 END, [ThemeType].[Type]
% 可以更改的地方,但所有这些都表明不是空值....
这是数据源:
<asp:SqlDataSource ID="SqlDataSource6" runat="server"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT [Theme].[Name], [ThemeType].[Type] FROM [Theme] Left Outer Join [ThemeType] ON [Theme].[ThemeTypeId] = [ThemeType].[PK_ThemeType] ORDER BY CASE WHEN [ThemeType].[Type] IS NULL THEN 1 ELSE 0 END, [ThemeType].[Type]">
<SelectParameters>
<asp:QueryStringParameter Name="changeParam" Type="String" />
</SelectParameters>