Last post Oct 28, 2010 04:44 AM by StevenF1976
Oct 27, 2010 12:25 PM|StevenF1976|LINK
I am storing a custom "Organisation" object as a session variable. One of the properties of the Organisation object is "OrganisationID" (integer).
I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
<asp:SessionParameter Name="OrganisationID" SessionField="OrganisationID" Type="Int32" />
However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")?
I have tried this, which does not seem to work:
<asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />
Oct 27, 2010 01:15 PM|sansan|LINK
Session Parameter checks for Key in session with FieldName that you specify and substitutes the value from key-value pair. It will not evaluate object property. You will have to set the value in Page Load or some other event. Instead of saving the object,
you can save ID.
Oct 28, 2010 04:44 AM|StevenF1976|LINK
OK, many thanks for the clarification that Session Parameter cannot evaluate an object property. Useful to know, but a shame, as it could have simplified the organisation of session variables.
I will just have to go back to using a separate "OrganisationID" session variable as before, for use with datasource session parameters.