Skip to main content
added 2621 characters in body
Source Link

Update:

Where is the code for the dropdownlist controls? To get an idea of the code we need to see, below is some editorpart code that I have used before. This is an editor part that uses the PeopleEditor control to allow you to select a user that the webpart renders.

public class UserDataEditorPart : EditorPart
{
    PeopleEditor _p;

    /// <summary>
    /// Constructor for the class.
    /// </summary>
    public UserDataEditorPart()
    {
        this.Title = "UserID Information";
    }

    /// <summary>
    /// This method is called by the ToolPane object to apply property changes to the selected Web Part. 
    /// </summary>
    public override bool ApplyChanges()
    {
        // Apply property values here.
        UserDataWebPart wp1 = (UserDataWebPart)this.WebPartToEdit;
        try
        {
            wp1.StoredUserID = _p.CommaSeparatedAccounts;
            return true;
        }
        catch
        {
            return false;
        }
    }

    /// <summary>
    /// If the ApplyChanges method succeeds, this method is called by the ToolPane object
    /// to refresh the specified property values in the toolpart user interface.
    /// </summary>
    public override void SyncChanges()
    {
        // Sync with the new property changes here.
    }

    /// <summary>
    /// Render this tool part to the output parameter specified.
    /// </summary>
    /// <param name="output">The HTML writer to write out to </param>
    protected override void Render(HtmlTextWriter output)
    {
        output.Write("Domain UserID (Domain\\UserID):");
        output.Write("<br>");
        _p.RenderControl(output);
        output.Write("<br><div style='width:100%' class='UserDottedLine'></div>");
    }

    protected override void CreateChildControls()
    {
        UserDataWebPart wp1 = (UserDataWebPart)this.WebPartToEdit;
        _p = new PeopleEditor();
        _p.ID = wp1.ID + "_PeopleEditor";
        _p.AllowEmpty = true;
        _p.AllowTypeIn = true;
        _p.MultiSelect = false;
        _p.PlaceButtonsUnderEntityEditor = false;
        _p.SelectionSet = "User";
        _p.Width = Unit.Pixel(195);
        _p.CommaSeparatedAccounts = wp1.StoredUserID;
        _p.PrincipalSource = SPPrincipalSource.UserInfoList;
        Controls.Add(_p);
    }
}

Update:

Where is the code for the dropdownlist controls? To get an idea of the code we need to see, below is some editorpart code that I have used before. This is an editor part that uses the PeopleEditor control to allow you to select a user that the webpart renders.

public class UserDataEditorPart : EditorPart
{
    PeopleEditor _p;

    /// <summary>
    /// Constructor for the class.
    /// </summary>
    public UserDataEditorPart()
    {
        this.Title = "UserID Information";
    }

    /// <summary>
    /// This method is called by the ToolPane object to apply property changes to the selected Web Part. 
    /// </summary>
    public override bool ApplyChanges()
    {
        // Apply property values here.
        UserDataWebPart wp1 = (UserDataWebPart)this.WebPartToEdit;
        try
        {
            wp1.StoredUserID = _p.CommaSeparatedAccounts;
            return true;
        }
        catch
        {
            return false;
        }
    }

    /// <summary>
    /// If the ApplyChanges method succeeds, this method is called by the ToolPane object
    /// to refresh the specified property values in the toolpart user interface.
    /// </summary>
    public override void SyncChanges()
    {
        // Sync with the new property changes here.
    }

    /// <summary>
    /// Render this tool part to the output parameter specified.
    /// </summary>
    /// <param name="output">The HTML writer to write out to </param>
    protected override void Render(HtmlTextWriter output)
    {
        output.Write("Domain UserID (Domain\\UserID):");
        output.Write("<br>");
        _p.RenderControl(output);
        output.Write("<br><div style='width:100%' class='UserDottedLine'></div>");
    }

    protected override void CreateChildControls()
    {
        UserDataWebPart wp1 = (UserDataWebPart)this.WebPartToEdit;
        _p = new PeopleEditor();
        _p.ID = wp1.ID + "_PeopleEditor";
        _p.AllowEmpty = true;
        _p.AllowTypeIn = true;
        _p.MultiSelect = false;
        _p.PlaceButtonsUnderEntityEditor = false;
        _p.SelectionSet = "User";
        _p.Width = Unit.Pixel(195);
        _p.CommaSeparatedAccounts = wp1.StoredUserID;
        _p.PrincipalSource = SPPrincipalSource.UserInfoList;
        Controls.Add(_p);
    }
}
Source Link

Do you have viewstate turned on? When are these controls created, in createchildcontrols? Are you adding them to the controls collection? Are you storing the value of this dropdown list in a webpart property? Are you setting the selectedindex after creating the control?

It would help you posted your editorpart code.