G
Guest
I'm being driven nuts by what I'm sure is a simple solution, I have to pass
some user and company id variables between 2 pages and on the second page
use the params in a SQL query to list all items for that company.
I set up the pages simply at first and could see the variables were being
passed. When I added my gridview and sqldatasource nothing happened and it
looks like the datasource is not picking up the session variable and I'm
stumped as I can see the variable fine on screen as per my code below.
Any help gratefully received
Regards
Jim Florence
On the first page, (I added 77 as a variable I knew would return results)
Session("Company") = 77
Session("usr") = strUser
Response.Redirect("testpage.aspx")
On the second page
This shows the variables have been carried across OK, and I can see them
fine on the screen
Dim companytst, usr
companytst = Session("Company")
usr = Session("usr")
Response.Write("company id")
Response.Write(companytst)
Response.Write("user")
Response.Write(usr)
This is the query I set up and the session parameter is set to pick up the
session variable Company
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT
Asset_Details.Serial_Number_sf_hd_mf_cb_ao_uq,
Asset_Details.Current_Contract_id_sf_rf, Asset_Details.Description_mf_cb_hd,
Asset_Details.Current_Job_No_rf, Asset_Details.Current_Installation_id_ao,
CONVERT (varchar(11), Asset_Details.Last_On_Hire_Date_rf, 106) AS Expr1,
Job_Details.Client_Reference FROM Asset_Details LEFT OUTER JOIN Job_Details
ON Asset_Details.Current_Job_No_rf = Job_Details.Job_No_hd_sf_cb_rf_nn WHERE
(Asset_Details.Current_Company_id_sf_ao = @Company) ORDER BY
Asset_Details.Serial_Number_sf_hd_mf_cb_ao_uq">
<SelectParameters>
<asp:SessionParameter Name="Company" SessionField="Company"
/>
some user and company id variables between 2 pages and on the second page
use the params in a SQL query to list all items for that company.
I set up the pages simply at first and could see the variables were being
passed. When I added my gridview and sqldatasource nothing happened and it
looks like the datasource is not picking up the session variable and I'm
stumped as I can see the variable fine on screen as per my code below.
Any help gratefully received
Regards
Jim Florence
On the first page, (I added 77 as a variable I knew would return results)
Session("Company") = 77
Session("usr") = strUser
Response.Redirect("testpage.aspx")
On the second page
This shows the variables have been carried across OK, and I can see them
fine on the screen
Dim companytst, usr
companytst = Session("Company")
usr = Session("usr")
Response.Write("company id")
Response.Write(companytst)
Response.Write("user")
Response.Write(usr)
This is the query I set up and the session parameter is set to pick up the
session variable Company
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT
Asset_Details.Serial_Number_sf_hd_mf_cb_ao_uq,
Asset_Details.Current_Contract_id_sf_rf, Asset_Details.Description_mf_cb_hd,
Asset_Details.Current_Job_No_rf, Asset_Details.Current_Installation_id_ao,
CONVERT (varchar(11), Asset_Details.Last_On_Hire_Date_rf, 106) AS Expr1,
Job_Details.Client_Reference FROM Asset_Details LEFT OUTER JOIN Job_Details
ON Asset_Details.Current_Job_No_rf = Job_Details.Job_No_hd_sf_cb_rf_nn WHERE
(Asset_Details.Current_Company_id_sf_ao = @Company) ORDER BY
Asset_Details.Serial_Number_sf_hd_mf_cb_ao_uq">
<SelectParameters>
<asp:SessionParameter Name="Company" SessionField="Company"
/>