Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

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.
0
Howard Bash
Asked:
Howard Bash
  • 3
  • 2
2 Solutions
 
jinalCommented:
<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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
NazoUKCommented:
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now