Simon,
Here is my VB.Net code behind:
Partial
Class PolicyValuesDetails
Inherits System.Web.UI.UserControl
Private _dataItem As Object = Nothing
#Region
"Web Form Designer generated code"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub 'OnInit
'/ <summary>
'/ Required method for Designer support - do not modify
'/ the contents of this method with the code editor.
'/ </summary>
Private Sub InitializeComponent()
AddHandler DataBinding, AddressOf Me.PolicyValuesDetails_DataBinding
End Sub 'InitializeComponent
#End
Region
Public Property DataItem() As Object
Get
Return Me._dataItem
End Get
Set(ByVal value As Object)
Me._dataItem = value
End Set
End Property
Protected Sub PolicyValuesDetails_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs)
cbPolicyAccountValueSource.DataSource = LifePolicyAccountValue.PolicyAccountValueSources
cbPolicyAccountValueSource.DataBind()
cbPolicyAccountValueSource.SelectedValue = DataBinder.Eval(DataItem,
"PolicyAccountValueSourceEnumId")
End Sub
End
Class
Here is my ASCX code for the radComboBox:
<
telerik:RadComboBox ID="cbPolicyAccountValueSource"
TabIndex="2"
DataTextField="value"
DataValueField="key"
runat="server">
</telerik:RadComboBox>
This line of VB.Net.
cbPolicyAccountValueSource.SelectedValue = DataBinder.Eval(DataItem, "PolicyAccountValueSourceEnumId")
is where I want to set the selectedvalue. In debug mode, DataBinder.Eval(DataItem, "PolicyAccountValueSourceEnumId")
= 2 which is correct. But the first value is always selected.
I stripped out all the AJAX stuff too thinking this was the problem. But it still does not work. Please note that this is a user control that displays when the Edit button is clicked on a radGrid which resides in another user control. It is impossible to send you a working version since my client will not allow it. But I do not understand why this does not work. When I try to set the SelectedValue with the correct value, it just does not work.
Thanks,
Bob