dave-g-o
December 15th, 2006, 09:04 AM
hello,
I have a webpart which is a webusercontrol. This web part is added to a web part zone using the web part catalog control. When i put the webpartmanager into edit mode i want to edit the menucontrol within this webpart. I have no problem editing labels / textboxes etc but adding items to a menu control via the webpart edit mode causes a problem.
Here is the code inside my webusercontrol:
Dim mItem As New MenuItem
Dim mItem1 As New MenuItem
Dim i As Integer
Private _text As String
Dim menuItem As New MenuItem
<WebBrowsable()> _
<Personalizable()> _
Public Property Edit() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
mItem1.Text = value
Menu1.Items.Add(mItem1)
End Set
End Property
so I gointo edit mode of the webpart > enter a property value for the first item to add to the menu > click submit the aspx page refreshes and the menu now has its first menu item.
But. When i repeat the process the propertyGridEditor gives the following error: Error setting property value: Index must be within the bounds of the List. Parameter name: index
I have a webpart which is a webusercontrol. This web part is added to a web part zone using the web part catalog control. When i put the webpartmanager into edit mode i want to edit the menucontrol within this webpart. I have no problem editing labels / textboxes etc but adding items to a menu control via the webpart edit mode causes a problem.
Here is the code inside my webusercontrol:
Dim mItem As New MenuItem
Dim mItem1 As New MenuItem
Dim i As Integer
Private _text As String
Dim menuItem As New MenuItem
<WebBrowsable()> _
<Personalizable()> _
Public Property Edit() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
mItem1.Text = value
Menu1.Items.Add(mItem1)
End Set
End Property
so I gointo edit mode of the webpart > enter a property value for the first item to add to the menu > click submit the aspx page refreshes and the menu now has its first menu item.
But. When i repeat the process the propertyGridEditor gives the following error: Error setting property value: Index must be within the bounds of the List. Parameter name: index