Solved

Using SessionParameter

Posted on 2009-06-27
6
246 Views
Last Modified: 2013-11-07
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
Comment
Question by:Howard Bash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 250 total points
ID: 24730049
<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
 
LVL 15

Expert Comment

by:jinal
ID: 24730050
<asp:SessionParameter Name="pClientGUID" SessionField="SessionInfo.ClientGUID"
 Type="String" />
0
 
LVL 15

Expert Comment

by:jinal
ID: 24730053
I forgot to mention in my previous comment that
you also have to specify DefaultValue="".
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 1

Author Comment

by:Howard Bash
ID: 24730068
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
 
LVL 15

Assisted Solution

by:NazoUK
NazoUK earned 250 total points
ID: 24731416
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
 
LVL 1

Author Comment

by:Howard Bash
ID: 24731885
That works.  Great.  It's unfortunate that I cannot use my SessionInfo class directly...  But it works.  Thanks.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question