I have many databases in web.config connectionstring plus I have multiple platforms like UAT system and PRD system. In the AppSettings I coded:
<add key="Platform" value="UAT"/>
and in ConnectionStrings I have for example:
<add name="PRD_OAM" connectionString=....
<add name="UAT_OAM" connectionString=....
What I would like to do on an aspx web page code:
<asp:TemplateField HeaderText="OAM<br />Service Line"
ItemStyle-HorizontalAlign="Center" SortExpression="Service_Line">
<EditItemTemplate>
<asp:DropDownList ID="ddlEditService_Lines" runat="server"
DataSourceID="sqlEditGet_Service_Lines"
AppendDataBoundItems="True"
DataTextField="Service_Line"
DataValueField="Service_Line_ID"
BackColor="LemonChiffon"
CssClass="control">
<asp:ListItem Text="No Service Line" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="sqlEditGet_Service_Lines" runat="server"
--- Problem ----> ConnectionString="'<%$appSettings: Platform %>'+'_OAM'"
SelectCommand="sp_OAM_Get_Service_Lines"
SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate> <%# Eval("Service_Line")%> </ItemTemplate>
</asp:TemplateField>
Prior to building & publishing the code I change the Platform value to swing the code from one system to another before publishing to the system.
Where Im struggling is with web pages that use SqlDataSource & Connectionstring within the EditItemTemplate. In all other cases Ive resolved any issues. Can this be done? If not, what about in the code behind? There I run into the problem of the connection string is not initialized in the OnRowEdit routine.
Im working with VS 2010 and Net 3.5 using C#.
Thanks for any help you can provide!