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.
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!
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!