2011-05-11 83 views
0

我试图在web.config文件的appsettings中设置我的gridview webpart在SharePoint站点上的行限制。ConfigurationSettings.AppSettings - 此方法已过时错误

<appSettings> 
<add key ="RowLimit" value="6"/> 
<add key="FeedCacheTime" value="300" /> 
<add key="FeedPageUrl" value="/_layouts/feed.aspx?" /> 
<add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" /> 
<add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> 

,然后在我的代码文件中,我使用下面的语句

string x = ConfigurationSettings.AppSettings["RowLimit"]; 

此行给了一个错误,说明ConfigurationSettings.AppSettings“此方法已过时”,

这是我做错了什么?请告诉我。

回答

3

您应该使用ConfigurationManager类代替。在.NET 2.0中已弃用ConfigurationSettings。使用方法与使用ConfigurationSettings相同,但请注意,如果您还没有添加对System.Configuration的引用,请注意。

+0

谢谢你这么多,这有助于 – Janet 2011-05-11 17:53:07

0

更换是System.Configuration.ConfigurationManager.AppSettings

例子:

using System.Configuration; 
... 
string x = ConfigurationManager.AppSettings["RowLimit"]; 
相关问题