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

Pre-select in related ComboBoxes

4 Answers 99 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ToMa
Top achievements
Rank 1
ToMa asked on 18 Sep 2010, 12:19 AM
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

4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 23 Sep 2010, 03:00 PM
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
0
ToMa
Top achievements
Rank 1
answered on 23 Sep 2010, 06:29 PM
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?
0
Simon
Telerik team
answered on 24 Sep 2010, 08:46 AM
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
0
ToMa
Top achievements
Rank 1
answered on 29 Sep 2010, 09:04 PM
Yep, it works ;-)
Thank you Simon
Tags
ComboBox
Asked by
ToMa
Top achievements
Rank 1
Answers by
Simon
Telerik team
ToMa
Top achievements
Rank 1
Share this question
or