Hi
I've got 3 connection strings in my app:
<add name="DBConnectionString" connectionString=""/>
<add name="ADConnectionString" connectionString="" />
<add name="TestDBConnectionString" connectionString="" />
now in the code i do:
public static string DefaultConnection
{
get
{
// this is used so that there will be no chance of modifing the original data when testing locally
if (HttpContext.Current.Server.MachineName == "xxx")
return ConfigurationManager.ConnectionStrings["TestDBConnectionString"].ConnectionString;
else
return ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
}
}
and this works in code behind, but when I do ordinary SqlDataSource and then do i like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%# DBConnections.DefaultConnection %>" />
I get: The ConnectionString property has not been initialized. What am I doing wrong? AFAIK this should get the value I want...
I don't want to do in connections section as I WANT TO BE SURE that I don't mess up the production server since I'm in the same network... I could do the whole publishing project but that's waaaaaaaaaaaay too much work.