我目前正在开发一个 SharePoint Web 部件,它将根据列表填充一些内容。一切都按预期工作,但我似乎无法访问包含所有列表项的变量!
我要访问的变量是theValue1
.
代码:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Administration;
namespace SPListWebPart.VisualWebPart1 {
public partial class VisualWebPart1UserControl : UserControl {
public void Page_Load(object sender, EventArgs e) {
string theValue1;
SPSite site = new SPSite("http://maindt/sites/dev");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Links"];
foreach (SPListItem item in list.Items) {
theValue1 = item["URL"].ToString();
}
}
}
}