Declarative SQL Problem
Dec 19, 2006I can't figure out what is wrong with the code below.
The first line prints out correctly when I am logged in
If I substitute the actual username in the SQL, the Repeater works fine, printing out the item from the db.
But using
WHERE USERNAME='<%= User.Identity.Name%>'
in the SelectCommand returns no rows.
Can anyone help?
Thanks,
Michael
<h3>News for <%=User.Identity.Name%></h3>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NEWWEB %>"
ProviderName="<%$ ConnectionStrings:NEWWEB.ProviderName %>"
SelectCommand="SELECT USERNAME FROM ASPNET_MEMBERSHIP WHERE USERNAME='<%= User.Identity.Name%>' ">
</asp:SqlDataSource>
<asp:Repeater ID="FirmAlertsRepeater" runat="server" DataSourceID="SqlDataSource2">
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "USERNAME")%></b> — <br />
</ItemTemplate>
</asp:Repeater>