【问题标题】:ASP.NET ObjectDataSource - reference static properties for parameter namesASP.NET ObjectDataSource - 参数名称的引用静态属性
【发布时间】:2009-02-04 17:46:18
【问题描述】:

我在我的网站项目中使用了很多 ObjectDataSources (ods)。几乎我所有的 ods 都使用 SessionParameters;在 ods 的 SessionField 属性中键入会话参数名称很烦人并且容易出现拼写错误。

我有一个静态 SessionParams 类,我在其中存储所有会话参数名称,是否可以在 ods 中引用该类的成员?我试过这样做,但没有成功。

这是我现在拥有的:

<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>

这就是我想要的:

<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>

【问题讨论】:

    标签: .net asp.net session .net-2.0


    【解决方案1】:

    据我所知,这些参数不是数据绑定的(也是默认值)。但你可以分配给他们@codebhind

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多