views:

584

answers:

1

I use a lot of ObjectDataSources (ods) in my website projects. Almost all of my ods's use SessionParameters; typing the session parameter name into the SessionField property of the ods is annoying and prone to typos.

I have a static SessionParams class where I store all the session parameter names, is it possible to reference the members of that class in the ods? I've tried to do it, but it never worked.

Here's what i have now:

<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetStuff" TypeName="RM.Stuff">
<SelectParameters>
    <asp:SessionParameter  SessionField="HAVE_TO_TYPE_EVERY_TIME" Name="somename" Type="Int32" />
</SelectParameters>

Here's what i want:

<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetStuff" TypeName="RM.Stuff">
<SelectParameters>
    <asp:SessionParameter  SessionField='<%= RM.SessionParams.SESSION_PAREMETER_NAME %>' Name="somename" Type="Int32" />
</SelectParameters>

+1  A: 

as far as i know, these parameters are not databind-able (also the defaultvalue). but you can assign them @codebhind

Andreas Niedermair