This code snippets will describe the way with which we can change the value of key present in the appsetting section of the web.config.
Suppose you have a key named Price as:
<add key="Price" value="5" />
and you want to change this value dynamically.
Code to Change the above Value: Namespace needs to added for this:
using System.Configuration;
using System.Web.Configuration;
Configuration myconf = WebConfigurationManager.OpenWebConfiguration("~");
myconf.AppSettings.Settings["Price"].Value = txtPrice.Text.Trim();
myconf.Save(); In the above code txtPrice.Text contains the new value for price.
Thanks & Regards
Lakhan Pal Garg