分类: 系统运维
2008-03-30 09:15:54
SPFieldUrl fieldUrl = (SPFieldUrl)item.Fields["URL"];
SPFieldUrlValue value = (SPFieldUrlValue)fieldUrl.GetFieldValue(item["URL"].ToString());
Console.WriteLine(value.Description);
Console.WriteLine(value.Url);
value.Url = "";
value.Description = "163";
fieldUrl.Update();
或者更简单的方法:
SPFieldUrlValue value = new SPFieldUrlValue(item["URL"].ToString());
Console.WriteLine(value.Description);
Console.WriteLine(value.Url);
设置
using (SPSite site = new SPSite("http://basesmcdev/sitedirectory/tester1"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["mosstestchoices"];
SPListItem item = list.GetItemById(3);
SPFieldUrlValue spfv = new SPFieldUrlValue(item["myhyperlink"].ToString());
spfv.Url = "";
spfv.Description = "new description";
item["myhyperlink"] = spfv.ToString();
item.Update();
}
}