This is a migrated thread and some comments may be shown as answers.

RadTreeList Template Column with DropDownList Loses Value on Postback

1 Answer 79 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Nader
Top achievements
Rank 1
Nader asked on 30 Jan 2015, 09:59 PM
I have a RadTreeList that contains a Template Column holding a DropDownlist.  I am populating the DropDownList during the ItemDataBound event:

Protected Sub RadTreeList1_ItemDataBound(sender As Object, e As TreeListItemDataBoundEventArgs) Handles RadTreeList1.ItemDataBound
If TypeOf e.Item Is TreeListEditableItem AndAlso CType(e.Item, TreeListEditableItem).IsInEditMode Then
Dim tmpItem As TreeListEditableItem = TryCast(e.Item, TreeListEditableItem)
Dim tmpControl As MultiView = TryCast(e.Item.FindControl("MultiView1"), MultiView)

Select Case tmpItem.DataItem("SelectionType").ToString
Case "DROPDOWN"
tmpControl.ActiveViewIndex = 0
Dim tmpDrop As DropDownList = TryCast(tmpControl.FindControl("DropDownList1"), DropDownList)

Using dbContext As New EntitiesModel
Dim tmpInt As Integer = tmpItem.DataItem("SowGroupID")
tmpDrop.AutoPostBack = True
tmpDrop.DataValueField = "SowSelectionID"
tmpDrop.DataTextField = "SelectionName"
tmpDrop.DataSource = dbContext.LibSOWSelections.Where(Function(c) c.SowGroupID = tmpInt).OrderBy(Function(c) c.Seq_No).ToList
tmpDrop.DataBind()
End Using
Case "CHECKBOX"
tmpControl.ActiveViewIndex = 1
Case "TEXTBOX"
tmpControl.ActiveViewIndex = 2
Case Else
tmpControl.ActiveViewIndex = 3
End Select
End If
End Sub

This works fine, but the problem is that I have the DropDownList posting back on change so that I can perform some logic, but when it posts back, I lose the selection of the dropdownlist.  It is rebinding and I do not know where I can capture the selected value.

Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 04 Feb 2015, 07:55 AM
Hi,

Since on expand and collapse the treelist is rebound and its items are recreated, you would need to manually persist your custom selection.  You could recognize the items by DataKeyValue and use it to keep their selection in a collection in the Session or the ViewState. Inside the DropDownList OnSelectedIndexChange event you could save the selected value in Session or ViewState and OnPreRender event of the DropDownList control persist these values.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeList
Asked by
Nader
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or