I'm selecting table data of the current user:
SELECT [ConfidenceLevel], [LoveLevel], [HappinessLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID)
I have set a control to the unique user ID and it is getting the correct value:
HTML: <asp:Label ID="userID" runat="server" Text="Labeluser"></asp:Label>
C#: userID.Text = Membership.GetUser().ProviderUserKey.ToString();
I then use it in the where clause using the Configure Data Source window
unique ID = control then controlID userID
(fills in .text for me)
I compile and run but nothing shows up where the table should be. Any suggestions?
Here is the code it has created:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ConfidenceLevel" HeaderText="ConfidenceLevel"
SortExpression="ConfidenceLevel" />
<asp:BoundField DataField="LoveLevel" HeaderText="LoveLevel"
SortExpression="LoveLevel" />
<asp:BoundField DataField="HappinessLevel" HeaderText="HappinessLevel"
SortExpression="HappinessLevel" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionStringToDB %>"
SelectCommand="SELECT [ConfidenceLevel], [LoveLevel], [HappinessLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID)">
<SelectParameters>
<asp:ControlParameter ControlID="userID" Name="UserProfileID"
PropertyName="Text" Type="Object" />
</SelectParameters>
</asp:SqlDataSource>