I am adding a radcombobox dynamically when certain parameters are met. This is happening inside an ajaxpanel in a user control. The code to add the combobox is as follows:
When the page is rendered, it is rendered correctly. So this all seems ok, except that the AddHandler is not firing. The code for the handler event is:
The code in the event handler works as i have tested this with just a regular asp dropdownlist. Why will it not work for radcombobox?
Walter Burditt
| Dim dropDownList As New RadComboBox |
| dropDownList.ID = associatedAttribute.Name |
| dropDownList.CssClass = "attributeDropdownList" |
| dropDownList.DataSource = associatedAttribute.AttributeItemCollection |
| dropDownList.DataTextField = "FormattedAmount" |
| dropDownList.DataValueField = "fldSkuSuffix" |
| dropDownList.DataBind() |
| dropDownList.Skin = "SkyBlue" |
| AddHandler dropDownList.SelectedIndexChanged, AddressOf dropDownList_SelectedIndexChanged |
| dropDownList.AutoPostBack = True |
| dropDownList.Items.Insert(0, New RadComboBoxItem("--Select--", String.Empty)) |
| If associatedAttribute.IsRequired Then |
| Dim rfv As New RequiredFieldValidator() |
| rfv.ControlToValidate = dropDownList.ID |
| rfv.Display = ValidatorDisplay.None |
| rfv.ErrorMessage = String.Format("Please Select", associatedAttribute.Name) |
| pnlProductAttributes.Controls.Add(rfv) |
| End If |
| pnlProductAttributes.Controls.Add(dropDownList) |
When the page is rendered, it is rendered correctly. So this all seems ok, except that the AddHandler is not firing. The code for the handler event is:
| Private Sub dropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) |
| Dim dropDownList As RadComboBox = TryCast(sender, RadComboBox) |
| If dropDownList IsNot Nothing Then |
| Dim myLabel As Label = TryCast(ThisPage.cartUpdatePanel.FindControl(dropDownList.ID), Label) |
| If myLabel IsNot Nothing Then |
| myLabel.Text = String.Format("<strong>{0}:</strong> {1}<br/>", dropDownList.ID, dropDownList.SelectedItem.Text) |
| End If |
| End If |
| Dim skuId As String = GetSku() |
| GetInventory(skuId) |
| End Sub |
The code in the event handler works as i have tested this with just a regular asp dropdownlist. Why will it not work for radcombobox?
Walter Burditt