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

Cascading DropDown or RadComboBox in RadGrid popup mode

6 Answers 367 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aaron Hanusa
Top achievements
Rank 1
Aaron Hanusa asked on 12 Nov 2009, 10:41 PM
I am using a RadGrid and utilizing the popup edit mode.

For simplicity sake, I have 2 DropDown lists (although these could easily be RadComboBoxes).  In the first one I have Countries, and the second one I have Cities.  Select a Country, the second DropDownList is populated with Cities.  Pretty standard functionality, nothing special here.

I would like to bind the selected values to an object's properties.  Lets say an Address object's .CountryID and .CityID properties for sake of argument.

<telerik:RadComboBox ID="ddlCountries" Runat="server" SelectedValue='<%#Bind("CountryID") %>' AutoPostBack="true" DataSourceID="countriesDataSource"  DataTextField="Country" DataValueField="CountryID"/>  
 
<telerik:RadComboBox ID="ddlCities" Runat="server" SelectedValue='<%#Bind("CityID") %>' DataSourceID="citiesDataSource"  DataTextField="City" DataValueField="CityID"/> 

ddlCountries can bind to the object fine in either edit or insert mode.  The problem lies in when ddlCities attempts to bind to the object.  I forget the exception that is thrown at this point, but it has something to do with ddlCities not being a bindable object.

I have figured out a solution to get this to work.  Admittedely, it is far more hackish than I hoped it to be.  I basically have to populate ddlCities manually after ddlCountries has changed and manually populate ddlCities with values (can't use a DataSource object).  What's worse is that I have to handle a few RadGrid events to manually select the City that should bind to the object's City property, rather than allow the elegance of the Bind() method to perform its work.  Again, it works, but it's quite an ugly solution.

Has anyone experienced this and have a code sample that they'd like to share?  I can share mine to upon request.

Thanks!

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 18 Nov 2009, 11:21 AM
Hi Aaron,

To see more information along the lines of the requested functionality, please refer to the following article:
http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in-radgrid.aspx

I hope it gets you started properly.


All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Aaron Hanusa
Top achievements
Rank 1
answered on 18 Nov 2009, 10:08 PM
Hi Pavlina,

Thanks for the reply and the code sample.  Unfortunately, the code does not address my issue.  In fact, you are using MORE code than my code, which I consider to be hackish.  Please don't take offense to that, but I think you may have missed my point as you aren't utilizing the Bind() method declaratively within the RadCombo's.

Thanks
0
Pavlina
Telerik team
answered on 20 Nov 2009, 04:29 PM
Hi Aaron,

Based on this information, it is hard to determine what is causing the issue you are facing. 
Therefore I will ask you to open a formal support ticket and provide us runnable example which replicates the error. Thus we'll be able to assist you further.

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Justin McMillen
Top achievements
Rank 1
answered on 12 Apr 2010, 05:29 PM
Have you been able to find a solution for this?  I am having the same problem.

Thanks.
0
Aaron Hanusa
Top achievements
Rank 1
answered on 12 Apr 2010, 06:02 PM
I don't believe I did.  I think I just moved on because Telerik wasn't addressing my issue.  Sorry...
0
Pavlina
Telerik team
answered on 15 Apr 2010, 03:10 PM
Hello Aaron and Justin,

I suggest you try out the following code to populate a combobox based on the selection in another combobox in the grid:
ASPX:
<telerik:GridTemplateColumn UniqueName="ContactTitle" HeaderText="ContactTitle">          
     <EditItemTemplate>   
         <telerik:RadComboBox ID="RadComboBox1" AutoPostBack="true" runat="server" SelectedValue='<%# Bind("CountryID") %>' DataSourceID="SqlDataSource1" DataTextField="CountryID"  OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">              
         </telerik:RadComboBox>            
     </EditItemTemplate>   
</telerik:GridTemplateColumn>   
     
<telerik:GridTemplateColumn UniqueName="TemplateColumn">   
     <EditItemTemplate>   
         <telerik:RadComboBox ID="RadComboBox2"  runat="server">   
         </telerik:RadComboBox>   
     </EditItemTemplate>   
</telerik:GridTemplateColumn>

C#:
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)   
    {   
        RadComboBox rdcbx = (RadComboBox)o;   
        GridEditableItem editedItem = rdcbx.NamingContainer as GridEditableItem;   
        RadComboBox ddList = editedItem.FindControl("RadComboBox2") as RadComboBox;   
        // change the data source for ddList here   
         .....          
    }

I hope this helps.

Greetings,
Pavlina
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.
Tags
Grid
Asked by
Aaron Hanusa
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Aaron Hanusa
Top achievements
Rank 1
Justin McMillen
Top achievements
Rank 1
Share this question
or