More in this section

Forums / Developing with Sitefinity / Bind RadControl ComboBox to Module.

Bind RadControl ComboBox to Module.

2 posts, 0 answered
  1. Owain
    Owain avatar
    110 posts
    Registered:
    17 Jan 2012
    30 May 2012
    Link to this post
    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.
  2. Owain
    Owain avatar
    110 posts
    Registered:
    17 Jan 2012
    30 May 2012
    Link to this post
    Cancel that, it really was a simple solution. Forgot to give DataValueField and DataTextField a value!

2 posts, 0 answered