Hi, I'm trying to retrieve the value of the Comments column in a document library but all I can get is the field name. This is my code...
... can you help me please?using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
BoundField bfield = new BoundField();
SPList list = web.Lists[List];
SPView view = list.Views[View];
SPListItemCollection items = list.GetItems(view);
SPFolder RootFolder = list.RootFolder;
string myComments = "";
foreach (SPFile file in RootFolder.Files)
{
if (file.Item.Fields.ContainsField("Comments"))
{
myComments = file.Item.Fields["Comments"].ToString();
}
string fileUrl = file.Item[SPBuiltInFieldId.EncodedAbsUrl] as string;
sb.AppendLine("<li>");
sb.AppendLine("<h3><a href='" + fileUrl + ">");
sb.AppendLine(file.Title);
sb.AppendLine("</a></h3>");
sb.AppendLine("<p>");
sb.AppendLine(myComments);
sb.AppendLine("<br/>");
sb.AppendLine(file.Name);
sb.AppendLine("</p>");
sb.AppendLine("</li>");
}
}
}
... can you help me please?using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
BoundField bfield = new BoundField();
SPList list = web.Lists[List];
SPView view = list.Views[View];
SPListItemCollection items = list.GetItems(view);
SPFolder RootFolder = list.RootFolder;
string myComments = "";
foreach (SPFile file in RootFolder.Files)
{
if (file.Item.Fields.ContainsField("Comments"))
{
myComments = file.Item.Fields["Comments"].ToString();
}
string fileUrl = file.Item[SPBuiltInFieldId.EncodedAbsUrl] as string;
sb.AppendLine("<li>");
sb.AppendLine("<h3><a href='" + fileUrl + ">");
sb.AppendLine(file.Title);
sb.AppendLine("</a></h3>");
sb.AppendLine("<p>");
sb.AppendLine(myComments);
sb.AppendLine("<br/>");
sb.AppendLine(file.Name);
sb.AppendLine("</p>");
sb.AppendLine("</li>");
}
}
}