It's boring and confused when we always insert nodes in appSettings. so let's defined ourselves nodes in Web.config
 
first:  we add new node in configSections. for example,  we add a new node StandardReports.
 
<configSections>
 <section name="StandardReports" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
 
in configSections, there two type nodes: one is declared section and the other declared sectionGroup. sectionGroup could contain several sections and sectionGroups 
 
second,  we add new items in our new node.
<configuration>
     <StandardReports>
          <add key="CategoryKPI" value="Rpt_CategoryKPI" />
     </StandardReports>
</configuration>
 
 
third, we get values such as this:
NameValueCollection config = (NameValueCollection)ConfigurationSettings.GetConfig("StandardReports");
string str = config["CategoryKPI"];
posted on 2009-04-29 14:24  蔡春升  阅读(170)  评论(0编辑  收藏  举报