Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to display data in details view control. Data will be the list of products ordered by the customer. I have created stored procedure to get this list and it works perfect. But on the web page, the list is not displayed, view is blank.
Since the product list belongs to the user who is currently logged in, I have taken Session as the 'Parameter source' and Session Field as'User.Identity.Name' for the details view control. Are these values wrong?

[Update]
ASP.NET
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource2" 
        style="z-index: 1; left: 338px; top: 222px; position: absolute; height: 121px; width: 175px">
        <Columns>
            <asp:BoundField DataField="textDesc" HeaderText="textDesc" 
                SortExpression="textDesc" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MYDataBaseConnectionString %>" 
        SelectCommand="VIEW_MY_ORDER" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:SessionParameter Name="CLIENT" SessionField="User.Identity.Name" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>


SQL query is producing correct results,I think the problem is in the above code
Posted
Updated 2-Nov-12 8:47am
v3
Comments
Sandeep Mewara 2-Nov-12 14:38pm    
It would be difficult until you share related code snippet.
WajihaAhmed 2-Nov-12 14:48pm    
Kindly see the updated part.
WajihaAhmed 2-Nov-12 15:10pm    
@Marcus Kramer: I am not able to view your answer, but after seeing my email notification, I rechecked the table. I do have a field textDesc with data type varchar(MAX)

1 solution

User.Identity.Name is not a SessionField. A session field is any field where you did something like Session["fieldName"] = User.Identity.Name. So, store User.Identity.Name into a SessionField, maybe called UserName and then change your session parameter to come from UserName.

C#
Session["UserName"] = User.Identity.Name;


HTML
SessionField="UserName" 
 
Share this answer
 
Comments
WajihaAhmed 2-Nov-12 15:29pm    
If I use Session["UserName"] = User.Identity.Name;, then How do I set the parameter source in the wizard? The options to be selected are:None, cookie, Form, control profile, QueryString, Session, Route Data.
ZurdoDev 2-Nov-12 15:31pm    
In your C# code, after validating that the user has logged in, you will fill in the session variable with User.Identity.Name. In the Wizard just choose Session and then type in UserName.
WajihaAhmed 3-Nov-12 4:34am    
I did as you told. In my validate_user(), I have
Session["UserName"] = User.Identity.Name;

and in the aspx file, I have:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MYDataBaseConnectionStringConnectionString %>"
SelectCommand="VIEW_MY_ORDER" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="CLIENT" SessionField="UserName" />
</SelectParameters>
</asp:SqlDataSource>


But still, no results being displayed :(
In my stored prosedure, I am just selecting the results, not returning them. Does this thing making the mistake?
ZurdoDev 3-Nov-12 17:19pm    
Selecting them does return them. I would implement the DataBinding event on the SQLDataSource. You can then look at the actual SQL command getting sent to SQL or just do a SQL trace. Also, Anonymous access needs to be turned off in IIS or else User.Identity.Name will be blank. Did you put a breakpoint and make sure that Session["UserName"] is getting filled in properly?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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