Bind RadControl ComboBox to Module.

Posted by Community Admin on 04-Aug-2018 15:06

Bind RadControl ComboBox to Module.

All Replies

Posted by Community Admin on 30-May-2012 00:00

This should be pretty straight forward but for what ever reason, I can't get it to work.
This is my code:

protected void Page_Load(object sender, EventArgs e)
    
 
        var dynamicModuleManagerDropdown = DynamicModuleManager.GetManager();
        Type myLocationType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.myLocations.myLocation");
 
        // This is how we get the collection of ContentPage items
        var mylocations = dynamicModuleManagerDropdown.GetDataItems(myLocationType).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
 
        RadComboBoxLocation.DataSource = mylocations;
        RadComboBoxLocation.DataBind();

On my aspx page I have a drop down list of locations, but when I select one of the locations from the list it presents me with:
Telerik.Sitefinity.DynamicTypes.Model.myLocations.myLocation


Instead of the item I have selected, as I say, this is probably a really simple thing I am missing.
Here is my aspx page:
<telerik:RadComboBox
ID="RadComboBoxLocation"
runat="server"
Height="200px"
Width="200px"
DropDownWidth="298px"
EmptyMessage="Select a location"
HighlightTemplatedItems="true"
EnableLoadOnDemand="true"
DataValueField="nameOfCourt"
>
                            <HeaderTemplate>
                                <table style="width: 275px" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td style="width: 177px;">
                                            Location name</td>
                                    </tr>
                                </table>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <div class="ddlocations">
                                       <%# DataBinder.Eval(Container.DataItem, "nameOfLocation")%>
                               </div>
                            </ItemTemplate>
                        </telerik:RadComboBox>

Thanks in advance.

Posted by Community Admin on 30-May-2012 00:00

Cancel that, it really was a simple solution. Forgot to give DataValueField and DataTextField a value!

This thread is closed