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

Unable to get value selected in one Radcombobox to OnItemsRequested event of the another RadComboxbox

4 Answers 335 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sarang
Top achievements
Rank 1
Sarang asked on 09 Dec 2011, 06:17 AM
There are two RadComboBox in RadGrid.  I need to filter the list of one combobox based on the selected value of the other RadComboBox.. 
If there is any solution to this problem kindly post as soon as possible.

The code that i have written on OnItemsRequested event of dependant RadComboBox is   
List<Item> oItemList = null;
            RadComboBox ddlItemName = (RadComboBox)sender;
            Item oItem = new Item();
            GridDataItem oGridDataItem = (GridDataItem)ddlItemName.Parent.Parent;
            if (!string.IsNullOrEmpty(e.Text))
            {
                oItem.ItemName = e.Text;
                if (oGridDataItem != null)
                {
                    RadComboBox ddlMake = (RadComboBox)oGridDataItem.FindControl("ddlMake");
                                  if (ddlMake != null && !string.IsNullOrEmpty(ddlMake.SelectedValue))
      
                                     
oItem.MakeId = Convert.ToInt64(ddlMake.SelectedValue);

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Dec 2011, 08:28 AM
Hello,

Try the following code snippet.
CS:
protected void RadComboBox2_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
   {
              ... ... ...
       string s = RadComboBox1.SelectedItem.Text;
   }

Thanks,
Princy.
0
Sarang
Top achievements
Rank 1
answered on 09 Dec 2011, 01:10 PM
Thanks for your replay..
But both the RadComboBox are resides into the grid. So For finding other RadComboBox, it  is necessary to find it out using find control.
Which is not giving recently selected value..

Aspx code is as follows
<telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Left" HeaderText="Make  ItemCode <br/> Item Name"
                                            ItemStyle-CssClass="gridItemStyle-40" HeaderStyle-CssClass="gridHeadStyle-40">
                                            <ItemTemplate>

                                                <br />
                                                <asp:LinkButton ID="lnkItem" runat="server" Visible="false" Text='<%#Eval("ItemName")%>'
                                                    OnClick="lnkItemName_Click" />
                                                <telerik:RadComboBox ID="ddlMake" Width="53%" runat="server" CssClass="drop-down-list"
                                                    EmptyMessage="Select a Make" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
                                                    DataTextField="MakeName" DataValueField="MakeId" EnableVirtualScrolling="true"
                                                    AutoPostBack="false" OnItemsRequested="ddlMake_ItemsRequested" OnSelectedIndexChanged="ddlMake_SelectedIndexChanged"
                                                    EnableItemCaching="true" Visible="true">
                                                </telerik:RadComboBox>
                                                <asp:HiddenField ID="MakeId" runat="server" Value="0" />
                                                <telerik:RadComboBox ID="ddlItemCode" runat="server" EmptyMessage="Select a ItemCode"
                                                    DataTextField="ItemCode" DataValueField="ItemId" EnableLoadOnDemand="True" ShowMoreResultsBox="true"
                                                    EnableVirtualScrolling="true" OnItemsRequested="ddlItemCode_ItemsRequested" Width="45%"
                                                    OnSelectedIndexChanged="ddlItemCode_SelectedIndexChanged" EnableItemCaching="true"
                                                    OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" Visible="true" MinFilterLength="0">
                                                </telerik:RadComboBox>
                                                <br />
                                                <telerik:RadComboBox ID="ddlItemName" runat="server" EmptyMessage="Select a ItemName"
                                                    DataTextField="ItemName" DataValueField="ItemId" EnableLoadOnDemand="True" ShowMoreResultsBox="true"
                                                    EnableVirtualScrolling="true" OnItemsRequested="ddlItemName_ItemsRequested" ChangeTextOnKeyBoardNavigation="true"
                                                    Width="99.4%" OnSelectedIndexChanged="ddlItemName_SelectedIndexChanged" EnableItemCaching="true"
                                                    MinFilterLength="0">
                                                </telerik:RadComboBox>
                                                <asp:LinkButton ID="lnkSplitItem" runat="server" OnClick="lnkSplitItem_Click" ForeColor="Red"
                                                    Font-Size="XX-Small" Visible="false">Split</asp:LinkButton>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Left"></ItemStyle>
                                        </telerik:GridTemplateColumn>

-Sarang
0
Sarang
Top achievements
Rank 1
answered on 10 Dec 2011, 05:14 AM
Hello Telerik Team,

Kindly suggest if there is any other solution to this problem.
For more explaination my requirment is there are two RadComboBox controls are in the grid.
For the both the radcomboboxs, load on demand property is set to  true.
User always select value of "Make" using  First combobox.
and then it will tab to next combobox. On the next combobox the expected item list will be populating using selected value of Make Combobox.

-Sarang
0
Dimitar Terziev
Telerik team
answered on 13 Dec 2011, 01:56 PM
Hello Sarang,

In order to achieve the desired functionality you could subscribe on the client-side OnClientSelectedIndexChange event of the first combobox and store the selected value in a hidden field. Then you should subscribe on the OnClientItemsRequesting event of the second combobox and pass the value from the hidden field through the context object as demonstrated in this help article here.

Greetings,
Dimitar Terziev
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
Sarang
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sarang
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or