To customize the Web Part Tool Part, im following this tutorial :
when i use On WebPart "with custom Tool Part" its work fine but when i add a Second web part "with custom Tool Part" in the same page and try to edit th custom property i got :
"The operation could not be completed because the Web Part was deleted by another user or is invalid."
Update :
public int _PaginationSize = 5;
[WebBrowsable(false)]
[Personalizable(PersonalizationScope.Shared)]
public int PaginationSize
{
get
{
return _PaginationSize;
}
set
{
_PaginationSize = value;
}
}
class Editor : Microsoft.SharePoint.WebPartPages.ToolPart
{
private DropDownList list;
private Label Name;
protected override void CreateChildControls()
{
ListeGroupes webPart = (ListeGroupes)this.ParentToolPane.SelectedWebPart;
if (WebPartToEdit == null)
return;
Name = new Label();
Name.Text = "Nbr elements : ";
Controls.Add(Name);
list = new DropDownList();
list.DataSource = new int[] { 1, 2, 3, 4, 5 };
list.DataBind();
this.Controls.Add(list);
base.CreateChildControls();
}
public override void ApplyChanges()
{
ListeGroupes webPart = (ListeGroupes)this.ParentToolPane.SelectedWebPart;
if (webPart != null)
webPart.PaginationSize = int.Parse(list.SelectedItem.Value);
}
public override void SyncChanges()
{
ListeGroupes webPart = this.WebPartToEdit as ListeGroupes;
if (webPart != null)
{
list.SelectedValue = webPart.PaginationSize.ToString();
}
}
public Editor(string webPartID)
{
this.ID = "Editor" + webPartID;
}
}