We help IT Professionals succeed at work.

Using SessionParameter

Medium Priority
264 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.
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
<asp:SessionParameter Name="pClientGUID" SessionField="SessionInfo.ClientGUID"
 Type="String" />

Commented:
I forgot to mention in my previous comment that
you also have to specify DefaultValue="".
Howard BashSenior Software Engineer

Author

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 ?

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Howard BashSenior Software Engineer

Author

Commented:
That works.  Great.  It's unfortunate that I cannot use my SessionInfo class directly...  But it works.  Thanks.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.