Here is how you can store your connection string in the config file and use it in your code:
<add key="ConString" value="Data Source={0};Initial Catalog={1};User ID={2};Password={3}" />
In your code behind:
string connection = (ConfigurationManager.ConnectionStrings["ConString"].ConnectionString).ToString();
SqlConnection con = new SqlConnection(string.Format(connection, datasource, database1, user_ID, pwd));