In a Gridview I have a column displaying number of entries in another table with ref.keys to the primary table.
The problem occurs when trying to pick only subtable entries visible for the specific user. Allthough the sessionParameter is only reffered to in the sub-select clause, the datagrid becomes empty when the "ses_user" sessionParameter is declared. Remove the parameter with sub-select reference and data is back.
Anyone who sees the logic of this or have a workaround?
Code:
<asp:SqlDataSource ID="SqlDataSourceGrid" runat="server" ConnectionString="<%$ ConnectionStrings:GTTConnectionString %>"
ProviderName="<%$ ConnectionStrings:GTTConnectionString.ProviderName %>"
SelectCommand="SELECT [Populasjon], [Aar], [Mnd], [Mnd_Halvdel], [PasientNr], [JournalNr], [Liggedager] ,(select count(*) from DBO.DataTriggere tr where tr.PasientNr=pas.PasientNr and userName=@ses_user) nTriggers FROM [DBO].[DataPasienter] pas
where pas.Aar=@valgt_aar and pas.mnd=@valgt_mnd and mnd_halvdel=@mnd_halvdel"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownListAar" Name="valgt_aar" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownListMnd" Name="valgt_mnd" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownListMndHalvdel" Name="Mnd_Halvdel" PropertyName="SelectedValue" />
<asp:SessionParameter Name="Ses_user" SessionField="userName" />
</SelectParameters>