Pre-select in related ComboBoxes

5 posts, 0 answers
  1. ToMa
    ToMa avatar
    10 posts
    Member since:
    Apr 2010

    Posted 17 Sep 2010 Link to this post

    Hi,
     there is a good example with related combos: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultvb.aspx
    I can't handle with pre-selection in last Combobox. For example if I choose Europe as continent, then France as country I would like to pre-select Paris as a city. I would know I wanted select Paris during Cities binding, becasue some indicator tells me about it during SELECT statement.

    Is it possible somewhere in code?

    I tried hard coding add RadComboBox3.SelectedIndex = "1" after DataBind() but with no result

    Protected Sub LoadCities(ByVal countryID As String)
                Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("TelerikConnectionString").ConnectionString)

                'select a city based on the countryID
                Dim adapter As New SqlDataAdapter("SELECT * FROM Cities WHERE CountryID=@CountryID ORDER By Name", connection)
                adapter.SelectCommand.Parameters.AddWithValue("@CountryID", countryID)

                Dim dt As New DataTable()
                adapter.Fill(dt)

                RadComboBox3.DataTextField = "Name"
                RadComboBox3.DataValueField = "ID"
                RadComboBox3.DataSource = dt
                RadComboBox3.DataBind()
            End Sub


    Thanks in advance for your help
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Sep 2010 Link to this post

    Hi ToMa,

    During a request for Items you can only load new Items in the RadComboBox. Changing properties of the control or other controls on the page will not have any effect on the client.

    In your case, you could handle the client-side ItemsRequested event of the third RCB and there preselect the 'Paris' Item if it exists. The approach is similar to that in the demo you referred to.

    I hope this helps.

    Regards,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. ToMa
    ToMa avatar
    10 posts
    Member since:
    Apr 2010

    Posted 23 Sep 2010 Link to this post

    Thank you Simon for your reply.
    After many and many tests I discovered this ;-( I also tried to call JavaScript function behind VB code but with no result.
    Problem is how to transfer ID which indicates the position on 3 RDB should be selected? I only know this get it from database.
    In example from my post I know that in third RDB should be French cities. Another select to database ponts on Paris as a capital - and then how to transfer it to client-side script?
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 24 Sep 2010 Link to this post

    Hi ToMa,

    You can set a custom attribute to that Item on the server, e.g. Item.Attributes["Default"] = true. Then in the client-side ItemsRequested event you can iterate through the Items in the ComboBox and select that with the set attribute. You can find more about the client-side API of RadComboBox and its helper objects in our help.

    Kind regards,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. ToMa
    ToMa avatar
    10 posts
    Member since:
    Apr 2010

    Posted 29 Sep 2010 Link to this post

    Yep, it works ;-)
    Thank you Simon
Back to Top