- Allow the user to select several configuration options from a drop down list.
- Each configuration option has a user control associated with it and when the user selects the option, the User Control with the configuration details must display allowing the user to capture some info.
- The user can select any number of configuration options, and this in itself might result in a very loooong form as more configuration choices are selected.
I'm hoping RadPanelBar can help prevent the form growing too long by allowing collapseing behaviour in the configuration section for me.
I keep track of the choices which the user has selected (in a hidden form variable) , and with each choice, the specific user control which must be loaded. The problem I'm currently facing is that the RadPanelBar only displays the very last item on PostBack, losing the controls from all previous choices. I reload the controls in the Page_Init event.
Private Property MyUsedControls As Dictionary(Of Long, MyUsedControl)Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init MyUsedControls = MyUsedControl.DeserializeReportList(Request.Form(HiddenField1.UniqueID)) 'Recreate the controls. At this stage, the RadPanelBar1.Items collection is empty For i As Integer = 0 To MyUsedControls.Count - 1 Dim ctrl As MyUsedControl = MyUsedControls(i) AddConfigurationControl(ctrl.ControlPath) NextEnd SubPrivate Sub AddConfigurationControl(ByVal cPath As String) Dim p As New RadPanelItem("Control No. " & RadPanelBar1.Items.Count) Dim uc As Control = LoadControl(cPath) Dim content As New RadPanelItem() content.Controls.Add(uc) p.Items.Add(content) RadPanelBar1.Items.Add(p)End SubProtected Sub RadComboBox1_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox1.SelectedIndexChanged 'Here we add the control to our "memory" of what controls we have so far used 'This is persisted into a hidden form variable without any problems MyUsedControls.Add( MyUsedControls.Count, New MyUsedControl With { .ID = RadPanelBar1.Items.Count, .ControlPath = RadComboBox1.SelectedValue } ) AddConfigurationControl(RadComboBox1.SelectedValue) RadComboBox1.ClearSelection()End SubYou can download a copy of the source code here: Sample Code: RadControlsWebApp1 (link expires 19 August 2012)