I have a RadComboBox control inside an EditTemplate of a GridView:
In the code-behind I databind the combo like this:
This produces an InvalidOperationException"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.". The error doesn't make much sense since the GridView is properly bound and other telerik controls, like
| <telerik:GridTemplateColumn HeaderText="Phone process" UniqueName="PhoneProcess" Display="false" EditFormColumnIndex="1"> |
| <EditItemTemplate> |
| <div style="width:30ex;margin-right:1ex;"> |
| <telerik:RadComboBox runat="server" ID="ddlPhoneProcess" |
| Width="100%" |
| EmptyMessage="No phone processes found" |
| AllowCustomText="false" |
| DataValueField="Key" |
| DataTextField="Value" |
| AppendDataBoundItems="true" |
| AutoPostBack="true" |
| OnSelectedIndexChanged="ddlPhoneProcess_SelectedIndexChanged" |
| SelectedValue='<%# Bind("PhoneProcessId")%>' |
| > |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="-- Not set --" Value="-1" Selected="true" /> |
| </Items> |
| </telerik:RadComboBox> |
| </div> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| RadComboBox combo = editItem["PhoneProcess"].FindControl("ddlPhoneProcess") as RadComboBox; |
| Dictionary<int, string> phoneProcesses = DataManagers.Proxy.DmPhone.GetPhoneProcesses(); |
| combo.DataSource = phoneProcesses; |
| combo.DataBind(); |
RadNumericTextBox
in other template columns bind with no problem.
If I databind the combo with DataSourceID="xxx" to a SqlDataSource, there is no error.
Could be that databinding via DataSource property somehow messes up the context of the databound control?