EditItemTemplate DropDownList ConnectionString using concatenated AppSettings + ConnectionString

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_OAMconnectionString=....

<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!

February 17th, 2015 6:57pm

Try asking in a Visual Studio forum. This one is for Visio

https://social.msdn.microsoft.com/Forums/vstudio/en-us/home?category=visualstudio

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:06am

Sorry ... I must have hit the wrong forum.
February 19th, 2015 1:12pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics