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

Related Combmoxes in grid, SelectedValue always blank!

1 Answer 31 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 17 Oct 2012, 04:56 PM
No matter what I try, the SelectedValue of the CountryCombo is always null, therefore I cannot load the Province/State Combo?

<telerik:RadComboBox ID="CountryCombo" runat="server" EnableLoadonDemand="true">
</telerik:RadComboBox>
 <telerik:RadComboBox ID="ProvinceCombo" runat="server" Width="325" EnableLoadonDemand="true">
</telerik:RadComboBox>

Private Sub RecipientsGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RecipientsGrid.NeedDataSource
 
Dim ctx As New DataEntities
 
RecipientsGrid.DataSource = ctx.RecipientOrganizations.ToList
 
AddOrganizationButton.Visible = False
RecipientOrganizationComboBox.Visible = False
 
   End Sub
    Private Sub RecipientsGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemCreated
       If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then

            Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim CountryCombo As RadComboBox = TryCast(editedItem.FindControl("CountryCombo"), RadComboBox)
            Dim ProvinceCombo As RadComboBox = TryCast(editedItem.FindControl("ProvinceCombo"), RadComboBox)

            AddHandler CountryCombo.ItemsRequested, AddressOf CountryCombo_ItemsRequested
            AddHandler ProvinceCombo.ItemsRequested, AddressOf ProvinceCombo_ItemsRequested

        End If
    End Sub
    Private Sub CountryCombo_ItemsRequested(sender As Object, e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)

        Dim Combo As RadComboBox = sender

        LoadCountries(Combo)

    End Sub

    Private Sub ProvinceCombo_ItemsRequested(sender As Object, e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)

        Dim Combo As RadComboBox = CType(sender, RadComboBox)
        Dim editedItem As GridEditableItem = CType(Combo.NamingContainer, GridEditableItem)
        Dim CountryCombo As RadComboBox = CType(editedItem.FindControl("CountryCombo"), RadComboBox)

        Dim _item As New RadComboBoxItemData()

        LoadProvinces(_item.Value, Combo)

    End Sub
   Protected Sub LoadCountries(ByVal Control As RadComboBox)

        Using context As New DataEntities
            With Control
                .DataValueField = "CountryId"
                .DataTextField = "CountryName"
                .DataSource = context.Countries.OrderBy(Function(x) x.displayOrder).ToList
            End With
            Control.Width = Unit.Pixel(320)
            Control.DataBind()
        End Using

    End Sub

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 22 Oct 2012, 12:28 PM
Hello Tim,

Here you can find a Code Library that uses cascading RadComboBoxes  in RadGrid Insert/Edit form. The implemented scenario is pretty close to your requirement.

Hope this will lead you into right direction.


Greetings,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Tim
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or