Posts

Showing posts from November, 2012

Export Gridview to PDF

http://www.dotnetspider.com/resources/29759-Exporting-GridView-PDF.aspx

Using the SharePoint ‘Person or Group’ field in code

 string[] Groupname = PLPSurveyAttendees.CommaSeparatedAccounts.Split(',');                                     string Users = string.Empty;                                     foreach (string survueygroupname in Groupname)                                     {                                         SPGroup ogrp = oWeb.Groups[survueygroupname];                                                                            Users += ogrp.ID.ToString() + ";#" + ogrp.Name.ToString() + ";#";                                      }                                     if (Users.EndsWith(";#"))                                     {                                         Users = Users.Substring(0, Users.Length - 2);                                     }                                     oListItem["Survey Attendees Group"] = Users;

Delete SharePoint Lists Programmatically

 using (SPSite osite = new SPSite("SiteURL"))             {                 using (SPWeb oweb = osite.OpenWeb())                 {                     SPListCollection olistcoll = oweb.Lists;                     Hashtable ht = new Hashtable();                     foreach(SPList olist in olistcoll)                     {                         if (olist.Title.StartsWith("Test"))                         {                             ht.Add(olist.ID, olist.Title);                                                  }                     }                     foreach (Guid ID in ht.Keys)                         olistcoll.Delete(ID);                 }             }