473,473 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Set <SelectParameters> To Constant Values

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?
Apr 5 '07 #1
2 4868
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>
<asp:Parameter Name="parameter1" Type="Int32" DefaultValue="<%$
AppSettings:Parameter1DefaultValue %>" />
</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>
<asp:Parameter 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" wrote:
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?
Apr 5 '07 #2
Yes, you are correct, that is what I meant, sorry for not being clear.
Also, that is exactly what I was looking for. Thank you very much.
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:08**********************************@microsof t.com...
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>
<asp:Parameter Name="parameter1" Type="Int32" DefaultValue="<%$
AppSettings:Parameter1DefaultValue %>" />
</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>
<asp:Parameter 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" wrote:
>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?

Apr 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arne Garvander | last post by:
How do I set parameters from code for a SqlDataSource? -- Arne Garvander (I program VB.Net for fun and C# to get paid.)
0
by: ~john | last post by:
I have an ObjectDataSource pointing at a class, which based on the SelectMethod and the parameter passed to it, returns an Object of my custom class. The SelectMethod is something like...
4
by: googlegroup | last post by:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionString:SalesDBConnectionString %>" SelectCommand="<%=strSQL%>" /> In ASP.NET , how do you assign a dynamic...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.