ASP.NET configure data source is not returning anything?

Posted by Greg McNulty on Stack Overflow See other posts from Stack Overflow or by Greg McNulty
Published on 2010-06-12T03:16:00Z Indexed on 2010/06/12 3:22 UTC
Read the original article Hit count: 308

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>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about sql