How to specify connection string from web.config inside the SqlDataSource

I have a connection string specified in my web.config file

      <add name="conn" connectionString="my string here" />

and here is my SqlDataSource:

 <asp:SqlDataSource ID="sds1" runat="server" ConnectionString ="<%$ ConnectionStrings:conn" %>" SelectCommand="SELECT Field1 FROM Table1"></asp:SqlDataSource>

I keep getting 2 errors:

1)The server tag is not well formed

and

2)Literal expressions like '<%$ ConnectionStrings:conn" %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ ConnectionStrings:conn"%>" /> instead.      

What am I doing wrong?
LVL 35
YZlatAsked:
Who is Participating?
 
hawks4everConnect With a Mentor Commented:
Instead of:
ConnectionString ="<%$ ConnectionStrings:conn" %>"

Try:
ConnectionString ="<%$ ConnectionStrings:conn %>"
0
 
deepu chandranCommented:
0
All Courses

From novice to tech pro — start learning today.