Search code examples
c#telerikevalrad-controls

Why does my control ID not work when I add an Eval statement to my Datatextfield?


code:

<telerik:RadComboBox runat="server" ID="CboLists"
DataTextField="<%# Eval("Attributes['listname']") %>" DataValueField="Id">
//rest of the combobox, includes an itemtemplate;

It works just fine without DataTextField="<%# Eval("Attributes['listname']") %>", but once I add this, CboLists turns red and it says "The name CboLists does not exist in the current context".

The combobox is populated on page load with a list of type Microsoft.Xrm.Sdk.Entity. I want to show a specific attribute of the selected entity if the combobox is not shown, but I cannot figure out how to show it.


Solution

  • Assuming your Eval is correct you need to using right combination of single and double quotes.

    <telerik:RadComboBox runat="server" ID="CboLists"
    DataTextField='<%# Eval(Attributes["listname"]) %>' DataValueField="Id">