M
MikeB
Hello All, how can I set my selectparameter to a constant value within my
constants class or to a value in my web.config file?
constants class or to a value in my web.config file?
Milosz Skalecki said:Howdy,
I guess meant data source controls (sqldatasource, objectdatasource etc)
1. First way in Web config:
<configuration>
<appSettings>
<add key="Parameter1DefaultValue" value="5"/>
</appSettings>
<system.web>
... everything else...
</system.web>
<configuration>
aspx page:
<asp:ObjectDataSource runat="server" ID="ds" SelectMethod="MethodName"
TypeName="ClassName" >
<SelectParameters>
<asparameter Name="parameter1" Type="Int32" DefaultValue="<%$
AppSettingsarameter1DefaultValue %>" />
</SelectParameters>
</asp:ObjectDataSource>
2. second apprach, contants class (set value programatically)
<asp:ObjectDataSource runat="server" ID="ds" SelectMethod="MethodName"
TypeName="ClassName" OnSelecting="ds_Selecting" >
<SelectParameters>
<asparameter Name="parameter1" Type="Int32"/>
</SelectParameters>
</asp:ObjectDataSource>
protected void ds_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["parameter1"] = 5; // use your contants here
}
Hope this helps
--
Milosz
MikeB said:Hello All, how can I set my selectparameter to a constant value within my
constants class or to a value in my web.config file?