Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Show nothing on using where clause in datalist , using session on where clause.
i am unable to understand that where is m fault, if i m using session so any data is not showing in output...

This Is my code


XML
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
                            <ItemTemplate>
                                id:
                                <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
                                <br />
                                image1:
                                 <asp:Image ID="image1Label" runat="server" ImageUrl='<%# Eval("image1") %>' Height="250px"
                                Width="225px" />

                                <br />
                                FirstName:
                                <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                                <br />
<br />
                            </ItemTemplate>
                            </asp:DataList>

                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                ConnectionString="<%$ ConnectionStrings:ModelsProfileConnectionString %>"
                                SelectCommand="SELECT * FROM [Pictures] WHERE ([FirstName] = @FirstName)">
                                <SelectParameters>
                                    <asp:SessionParameter Name="FirstName"  SessionField="FirstName" Type="String" />
                                </SelectParameters>
                            </asp:SqlDataSource>
Posted
Updated 5-Mar-15 4:59am
v2
Comments
Simon_Whale 5-Mar-15 11:11am    
have you verified that there is a value in the session parameter?
Aarti Yadav 5-Mar-15 11:23am    
yes i have verified there is a value in session parameter...
but still its not working i am afraid now...
Simon_Whale 5-Mar-15 11:33am    
can you modify the session parameter to include the following key DefaultValue="" and in between the speech marks add a value that you know will return a value
Aarti Yadav 5-Mar-15 11:36am    
oky, if i'll give a value in defaultvalue then data will show ?.
Simon_Whale 5-Mar-15 11:39am    
that means that somehow your session parameter is being cleared before the query is run. Is there something that causes the page to call a postback to the server?

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