jbrahy
asked on
how do I pass a parameter from web.config AppSettings to a SqlDataSource?
I was hoping to do something like this:
<SelectParameters>
<asp:Parameter DefaultValue="<%$ AppSettings:StatusID %>" Type="int32" Name="StatusID" />
</SelectParameters>
<SelectParameters>
<asp:Parameter DefaultValue="<%$ AppSettings:StatusID %>" Type="int32" Name="StatusID" />
</SelectParameters>
ASKER
I want to do it from the .aspx, is that possible?
see if you can:
<asp:Parameter DefaultValue="<%# system.Configuration.Confi gurationMa nager.AppS ettings("S TATUS_ID") %>" Type="int32" Name="StatusID" />
if not, then i would say stick with code-behind.
hth
<asp:Parameter DefaultValue="<%# system.Configuration.Confi
if not, then i would say stick with code-behind.
hth
Yes, you can, but you will still need to code some codebehind.
First declare a property like this, in your codebehind, this will get the appsettings val
public string StatusId
{
get
{
return system.Configuration.Confi gurationMa nager.AppS ettings("S TATUS_ID") ;
}
}
Now you can access the StatusId property in your aspx (markup page)
<%# StatusId()%>
for example if you want to set the text of a label
text='<%# TypeCode()%>'
First declare a property like this, in your codebehind, this will get the appsettings val
public string StatusId
{
get
{
return system.Configuration.Confi
}
}
Now you can access the StatusId property in your aspx (markup page)
<%# StatusId()%>
for example if you want to set the text of a label
text='<%# TypeCode()%>'
ASKER
can I put that codebehind in the a file in the App_Code directory so I don't have to modify every file?
The best thing would be to put it in a common class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, I was getting an unrelated error and after going back through it it's working. thanks!
Open in new window