Q:

How to use appSettings key in SqlDataSource

Web.config:
<appSettings file="Application.config">
        <add key="stringC" value="Data Source=svr1;Initial Catalog=myDB;Integrated Security=FALSE;user=user2;pwd=@#$123pop;" />
</appSettings>

ASP.net:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ {HOW TO USE THE APP SETTINGS KEY HERE} %>"
    SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors]" />

How do I replace the {HOW TO USE THE APP SETTINGS KEY HERE} with the application key.

A:

You could use <%$ ConfigurationSettings.AppSettings["stringC"] %>.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConfigurationSettings.AppSettings["stringC"] %>"
    SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors]" />

