sqlDataSource and Session Variable

MTSkull

Centurion
Joined
Mar 25, 2003
Messages
151
Location
Boulder, Colorado
I am trying to tie a sqlDatasource to a Stored Procedure.

The stored procedure looks like...
Code:
dbo.Select_SomeData_BySuperAssemID
(@SuperAssemID as int)

Select * 
From SomeTable
Where SuperAssemID= @SuperAssemID

Then the asp page is accessed via ...
Code:
Response.Redirect("DataPage.aspx?SuperID=" + ID);

In the code behind I can access and use Super ID no problem, but when I try to set up the SQL data source to access super ID it returns nothing.
My gridview is bound to the following control.
Code:
<asp:SqlDataSource ID="sqlSubAssemblies" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MyConnStr %>" 
            SelectCommand="Select_SomeData_BySuperID" 
            SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:SessionParameter Name="SuperAssemID"
                            SessionField="SuperID" Type="Int32" />
                </SelectParameters>
</asp:SqlDataSource>

Thanks in advance...
Brian
 
It looks as though you are passing the parameter as part of the query string, yet in the markup you are using a SessionParameter, are you copying the query string value into the session first? If not you could just use a <asp:QueryStringParameter .... instead.
 
How easy was that! I switched from session to Query String and passed the session variable as the value and presto it worked.

Your help is greatly Appreciated.
 
Back
Top