When a user logins to my application I am creating a session variable called 'User'. The user logins with their DXNumber)
I am then using this session as part of a datasource as below:
When I get the corresponding BusinessID, I populate a hidden label with the value
Then I link my data to the value in the label.
I am assuming that when the session expires then the value in the lblUserID is NULL which is giving me the Object reference error.
I obviously dont want to leave the session open indefinately but is there any code I can add that checks if its NULL then requery the value again or something?
Code:
Session("User") = txtDXNumber.Text
I am then using this session as part of a datasource as below:
Code:
<asp:sqldatasource runat="server" id="GetUserID"
ConnectionString="<%$ ConnectionStrings:FileawaySQLConnectionString %>"
SelectCommand="SELECT [BusinessID] FROM [Businesses] WHERE ([DXNumber] = @DXNumber)">
<SelectParameters>
<asp:SessionParameter Name="DXNumber" SessionField="User" Type="String" />
</SelectParameters>
</asp:sqldatasource>
When I get the corresponding BusinessID, I populate a hidden label with the value
Code:
Dim dvUserID As Data.DataView = GetUserID.Select(DataSourceSelectArguments.Empty)
Me.lblUserID.Text = dvUserID.ToTable.Rows(0)("BusinessID")
Then I link my data to the value in the label.
I am assuming that when the session expires then the value in the lblUserID is NULL which is giving me the Object reference error.
I obviously dont want to leave the session open indefinately but is there any code I can add that checks if its NULL then requery the value again or something?