Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show value in gridview for specific user. In 'Test Query' it works fine, but didn't show value on page. What's wrong?

ASP.NET
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="698px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="Idoferty">
            <Columns>
                <asp:BoundField DataField="Idoferty" HeaderText="Idoferty" SortExpression="Idoferty" />
            </Columns>
        </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ofety_stopowiczeV1ConnectionString %>" SelectCommand="SELECT [Idoferty] FROM [rezerwacje] WHERE ([user] = @user)">
                <SelectParameters>
                    <asp:SessionParameter Name="user" SessionField="User.Identity.Name" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>


SELECT statement
SQL
SELECT [Idoferty] FROM [rezerwacje] WHERE ([user] = @user)
Posted

1 solution

Either your SessionField is wrong or there is no data in Session.
Make sure the Session you set is User.Identity.Name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900