【问题标题】:RadComboBox not displaying bound dataRadComboBox 不显示绑定数据
【发布时间】:2013-05-29 21:39:02
【问题描述】:

我有一个像这样的 RadComboBox:

            <telerik:RadComboBox ID ="productsDropDown" DataValueField="DisplayName" DataTextField="DisplayName" HighlightTemplatedItems="true"
            runat="server" AllowCustomText="true" Height="150px" Width="200px" OnClientDropDownClosed="onDropDownProductClose" AutoPostBack="true">
                <ItemTemplate>
                    <div onclick="StopPropagation(event)">
                        <asp:CheckBox runat="server" ID="chk2" Checked="false" onclick="onCheckBoxProductClick(this)"/>
                        <asp:Label runat="server" ID="Label2" AssociatedControlID="chk2">
                            <%# Eval("DisplayName")%>
                        </asp:Label>
                    </div>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Button ID="btnSubmitProduct" runat="server" Text="OK" OnClick="OnSubmitProduct" />
                </FooterTemplate> 
            </telerik:RadComboBox>

但由于某种原因,它不会像这样显示我绑定到它的任何数据:

            productsDropDown.DataSource = FTSAppLogic.getProducts();
            productsDropDown.DataBind();

我有一个几乎相同的下拉菜单:

            <telerik:RadComboBox ID ="regionsDropDown" DataValueField="Region" DataTextField="Region" HighlightTemplatedItems="true"
            runat="server" AllowCustomText="true" Height="150px" Width="200px" OnClientDropDownClosed="onDropDownRegionClosing" AutoPostBack="true">
                <ItemTemplate>
                    <div onclick="StopPropagation(event)">
                        <asp:CheckBox runat="server" ID="chk1" Checked="false" onclick="onCheckBoxRegionClick(this)"/>
                        <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1">
                            <%# Eval("Region")%>
                        </asp:Label>
                    </div>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Button ID="btnSubmitRegion" runat="server" Text="OK" OnClick="OnSubmitRegion" />
                </FooterTemplate> 
            </telerik:RadComboBox>



            regionsDropDown.DataSource = FTSAppLogic.getRegions();
            regionsDropDown.DataBind();

它完美地显示了所有内容(它们的两个 get 函数几乎相同,返回相同的布局和相同的数据类型)

另外让事情变得更奇怪的是,我抛出了一个调试中断,发现数据绑定到productDropDown后,数据实际上是绑定的,它不会显示任何数据..

有人知道为什么吗?!我完全迷失了!!

【问题讨论】:

    标签: asp.net data-binding telerik radcombobox


    【解决方案1】:

    我认为你在项目模板中以错误的方式使用了标签:

    <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1">
             <%# Eval("Region")%>//this is wrong 
    </asp:Label>
    

    应该是:

    <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1" 
    Text='<%# Eval("Region")%>'</asp:Label>
    

    你需要将数据列分配给标签的文本字段,它是asp控件(不像HTML标签)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 2019-12-19
      • 2017-03-19
      • 2015-10-20
      相关资源
      最近更新 更多