Modify the value of key in appsetting section of web.config at runtime.
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:
and you want to change this value dynamically.
Code to Change the above Value:
Namespace needs to added for this:
Configuration myconf = WebConfigurationManager.OpenWebConfiguration("~");
myconf.AppSettings.Settings["Price"].Value = txtPrice.Text.Trim();
In the above code txtPrice.Text contains the new value for price.
Thanks & Regards
Lakhan Pal Garg