Using SessionParameter

I have a gridview with an sqldatasource as follows:
     
<asp:SqlDataSource ID="SqlDataSourceLocationList" runat="server"
      ConnectionString="<%$ ConnectionStrings:SOME_DSN %>"
      SelectCommand="select (FName + '.' + LName) as ContactName, C.Email, P.Phonenumber, P.LocationGuid from ClientLogin C, Phones P Where C.PhoneNumberGuid=P.PhoneNumberGuid and C.ClientGuid=@pClientGUID"
      SelectCommandType="Text"
    >
     
    <SelectParameters>
    <asp:SessionParameter  Name="pClientGUID" Direction="Input" SessionField="SessionInfo.ClientGUID" Size="36" />
    </SelectParameters>      

</asp:SqlDataSource>
 
On page load and unload I keep passing a class called "SessionInfo" that I manipulate and store/load.  I pass the ClientGuid as SessionInfo and cast it to my class type and access the various properties...

The associated grid comes back with 0 rows and I know that for the clientguid passed to the page via a session variable, there should be one row returned and have run the sql in management studio express.

Also note that the ClientGuid is of type uniqueidentifier. And that when I remove the parameter ( "and C.ClientGuid=@pClientGUID" ) and return all the table rows, the grid populates with data.

It might have to do with the Session

Thanks.
LVL 1
Howard BashSenior Software EngineerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jinalConnect With a Mentor Commented:
<asp:SessionParameter Name="pClientGUID" SessionField=SessionField="SessionInfo.ClientGUID"
 Type="String" />

I hope that this will help you and your SessionInfo.ClientGUID return some valid value.


 
0
 
jinalCommented:
<asp:SessionParameter Name="pClientGUID" SessionField="SessionInfo.ClientGUID"
 Type="String" />
0
 
jinalCommented:
I forgot to mention in my previous comment that
you also have to specify DefaultValue="".
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Howard BashSenior Software EngineerAuthor Commented:
I have tried your suggestion and still no rows returned...

Do you know of the routines/events to break in to see the sql before execution and the sessionparamter value ?

0
 
NazoUKConnect With a Mentor Commented:
I think SessionParameter only allows simple types, it won't evaluate a property of an object. If you want to use a SessionParameter you should store the value of ClientGUID on its own in a session variable.
0
 
Howard BashSenior Software EngineerAuthor Commented:
That works.  Great.  It's unfortunate that I cannot use my SessionInfo class directly...  But it works.  Thanks.
0
All Courses

From novice to tech pro — start learning today.