Gets a view of a list within the site based on the specified URL.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Function GetViewFromUrl ( _
listUrl As String _
) As SPView
用法
Dim instance As SPWeb
Dim listUrl As String
Dim returnValue As SPView
returnValue = instance.GetViewFromUrl(listUrl)
public SPView GetViewFromUrl(
string listUrl
)
参数
listUrl
类型:System.StringThe absolute or site-relative URL of the list for which the view is retrieved.
返回值
类型:Microsoft.SharePoint.SPView
The view of the list with the specified URL.
异常
| 异常 | 条件 |
|---|---|
| ArgumentNullException | listUrl is null . |
示例
The following code example uses the GetViewFromUrl method to return a view and uses the view to return and display items.
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Site_Name")
Dim list As SPList = webSite.Lists("List_Name")
Dim view As SPView = webSite.GetViewFromUrl("Lists/List_Name/View_Name.aspx")
Dim listItems As SPListItemCollection = list.GetItems(view)
Response.Write(SPEncode.HtmlEncode(listItems.Xml))
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
SPList oList = oWebsite.Lists["List_Name"];
SPView oView = oWebsite.GetViewFromUrl("Lists/List_Name/View_Name.aspx");
SPListItemCollection collListItems = oList.GetItems(oView);
Response.Write(SPEncode.HtmlEncode(collListItems.Xml));
}
备注
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.