protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string command = e.CommandName;
string path = e.CommandArgument.ToString();
if (path != "appSettings" && path != "connectionStrings")
path = "system.web/" + path;
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection(path);
if (command == "Encrypt")
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
}
else if (command == "Decrypt")
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}