protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SPFolderCollection sfc = SPContext.Current.Web.Folders; ddl_Destination.Items.Add("---Make a selection---"); foreach (SPFolder f in sfc.Cast <SPFolder>().OrderBy(t => t.Name)) { if (f.DocumentLibrary != null) { ddl_Destination.Items.Add(new ListItem(f.Name, f.Url)); } } SPListCollection lic = SPContext.Current.Web.Lists; ddl_Lists.Items.Add("---Make a selection---"); foreach (SPList l in lic.Cast <SPList>().OrderBy(t => t.Title)) { //if(l.BaseType == SPBaseType.f ddl_Lists.Items.Add(new ListItem(l.Title, l.ID.ToString())); } SPDocumentLibrary tempDocs = (SPDocumentLibrary)SPContext.Current.Web.Lists["Merge Templates"]; //lb_Templates.Items.Add(new ListItem("---Make a selection---","-1",true); foreach (SPListItem i in tempDocs.Items.Cast <SPListItem>().OrderBy(t => t.Name)) { lb_Templates.Items.Add(new ListItem(i.Name, i.UniqueId.ToString())); } lb_Templates.DataBind(); } }
public static IEnumerable <TList> GetListsByInternalName <TList>(this SPListCollection lists, string internalName) where TList : SPList { return(lists.Cast <TList>().Where(l => l.RootFolder.Name == internalName)); }