I have custom section Links which I Should edit from UI. While saving I couldn't save the value of the corresponding key. It shows "collection is read only" error. Please help me to resolve this. Thanks in Advance.
WebConfig
- <sectionGroup name="Menu">
- <section name="Links" type="System.Configuration.NameValueSectionHandler"/>
- </sectionGroup>
C#
- NameValueCollection nameValueCol = (NameValueCollection)ConfigurationManager.GetSection("Menu/Links");
- var Key = "Key";
- var Value = "Value";
- nameValueCol.Set(Key, Value);
so I tried to remove and add the keys still it shows same error.
- nameValueCol.Remove(Key);
- nameValueCol.Add(Key, Value);