Get column values of item in ItemAdding event handler

In an Item Adding event handler Properties.ListItem will be null. Same is the case with Properties.BeforeProperties & Properties.AfterProperties too. So how to get the values entered in the NewForm.aspx in the ItemAdding method. Here we go.. You can access the value using AfterProperties property. But here you have to pass the internal name of the... Continue Reading →


Adding values to SharePoint People Editor using code

I was working with the People Editor Control and realized there are a couple weird things you need to do before you can read values into the control and save values into a list.  Here is a samples related to saving multiple/single user details into a people or groups column in a list. SPFieldUserValueCollection UserCollection... Continue Reading →

SharePoint usage reports using object model

To get the usage details of the site we use the method site.GetUsage(SPUsageReportType , SPUsagePeriodType ). SPUsageReportType Enumeration The SPUsageReportType enumeration specifies the type of information returned in a usage report for a SharePoint site. The following table shows the members of the SPUsageReportType enumeration and a brief description Name Description browser The type of... Continue Reading →

Retrieving an attachment from an item using code

foreach (SPListItem attachItem in list.Items){if (Convert.ToString(attachItem["Request Number"]) == Convert.ToString(this.Page.Request.QueryString["reqno"])){foreach (string fileName in attachItem.Attachments){SPFile file = attachItem.ParentList.ParentWeb.GetFile(attachItem.Attachments.UrlPrefix + fileName);writer.RenderBeginTag(HtmlTextWriterTag.Tr);writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");writer.AddAttribute(HtmlTextWriterAttribute.Href, file.ServerRelativeUrl);writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "12px");writer.RenderBeginTag(HtmlTextWriterTag.A);writer.Write(file.Name);writer.RenderEndTag();flag = true;}break;}}

Create a website or blog at

Up ↑

%d bloggers like this: