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

Related ComboBoxes in a FormView?

1 Answer 77 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Shuja
Top achievements
Rank 1
Shuja asked on 03 Feb 2011, 07:54 PM
Hi,

I'm trying to get 2 related comboboxes to work in a formview (when you select an option from the 1st combobox then the 2nd one is populated by using the selected value from the 1st combobox as a parameter/filter).
The example for this on the Telerik site doesn't take into account controls in a formview or the fact that there might be form templates for Insert & Edit so the example fails.

Can you please let me know how i can get simple related combobox functionality (both combobox's are populated from a data source) to work when comboboxes are within a templated formview?

Regards,

Shuja 

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 04 Feb 2011, 09:46 PM
Hello Shuja,

Try something like this:

<telerik:RadComboBox ID="RadComboBox1" runat="server" DataValueField="Value1" DataTextField="Text1"
        DataSourceID="LinqDataSource1" AutoPostBack="true">
    </telerik:RadComboBox>
    <telerik:RadComboBox ID="RadComboBox2" runat="server" DataValueField="Value2" DataTextField="Text2"
        DataSourceID="LinqDataSource2">
    </telerik:RadComboBox>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LinqDataSource2" runat="server">
        <WhereParameters>
            <asp:ControlParameter ControlID="RadComboBox1" PropertyName="SelectedValue" Name="Value1" />
        </WhereParameters>
    </asp:LinqDataSource>

The second datasource, which is linked to the second RadComboBox has a ControlParameter that uses the SelectedValue from RadComboBox1. I set RadComboBox1 to AutoPostBack="true", so when the value changes, RadComboBox2 has the values related to the selection made in RadComboBox1.

I hope that helps.
Tags
ComboBox
Asked by
Shuja
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or