E
Erik Funkenbusch
ASP.NET 2.0
I have a SqlDataSource that i'd like to pass the UserID of the user defined
by the Membership provider.
So, I thought I'd do something like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:acpConnectionString %>"
SelectCommand="SELECT [balance] FROM [accounts] WHERE ([UserID] = @UserID)" EnableViewState="False">
<SelectParameters>
<asparameter Name="UserID" Type="Object" DefaultValue="<%= Membership.GetUser(false).ProviderUserKey %>"/>
</SelectParameters>
</asp:SqlDataSource>
ProviderUserKey is a GUID, and my SQL Data type is a uniqueidentifer. This
doesn't generate any kind of exception, but it just returns no data.
If, however, I use a SessionParameter, and copy the ProviderUserKey into a
Session variable, it works and returns the record as expected.
It seems like the ASP code in the Parameter tag isn't executing, any ideas
how to fix this? I'd rather not use the session variable if I don't have
to.
I have a SqlDataSource that i'd like to pass the UserID of the user defined
by the Membership provider.
So, I thought I'd do something like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:acpConnectionString %>"
SelectCommand="SELECT [balance] FROM [accounts] WHERE ([UserID] = @UserID)" EnableViewState="False">
<SelectParameters>
<asparameter Name="UserID" Type="Object" DefaultValue="<%= Membership.GetUser(false).ProviderUserKey %>"/>
</SelectParameters>
</asp:SqlDataSource>
ProviderUserKey is a GUID, and my SQL Data type is a uniqueidentifer. This
doesn't generate any kind of exception, but it just returns no data.
If, however, I use a SessionParameter, and copy the ProviderUserKey into a
Session variable, it works and returns the record as expected.
It seems like the ASP code in the Parameter tag isn't executing, any ideas
how to fix this? I'd rather not use the session variable if I don't have
to.