using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using Microsoft.SharePoint; namespace FormGenerator { class FormGeneratorToolPart: Microsoft.SharePoint.WebPartPages.ToolPart { FormGenerator oFG; Panel oToolPartPanel; DropDownList oDDLListProvider; protected override void CreateChildControls() { base.CreateChildControls(); oToolPartPanel = new Panel(); Controls.Add(oToolPartPanel); oDDLListProvider = new DropDownList(); oToolPartPanel.Controls.Add(oDDLListProvider); PopulateProviderList(); } private void PopulateProviderList() { SPListCollection myListCol = SPContext.Current.Web.Lists; oDDLListProvider.AppendDataBoundItems = true; foreach (SPList myList in myListCol) { ListItem myListItem = new ListItem(myList.Title, myList.Title); oFG = (FormGenerator)this.ParentToolPane.SelectedWebPart; if (oFG.FormList == myList.Title) myListItem.Selected = true; oDDLListProvider.Items.Add(myListItem); } } public override void ApplyChanges() { base.ApplyChanges(); oFG.FormList = oDDLListProvider.SelectedValue; } public override void SyncChanges() { base.SyncChanges(); oDDLListProvider.SelectedValue = oFG.FormList.ToString(); } protected override void RenderToolPart(System.Web.UI.HtmlTextWriter output) { output.Write("List Name Lookup:"); output.Write("

"); oDDLListProvider.RenderControl(output); output.Write("
 

"); } } }