The ComboBox is displayed in a RadGrid under the ItemTemplate (yes, not EditItemTemplate).
The problem is I get an error that says "The target {obj} for the callback could not be found or did not implement the ICallbackEventHandler.
What am I missing? Here is my aspx:
<
telerik:GridTemplateColumn
HeaderText
=
"Employee Type"
DataType
=
"System.String"
>
<
ItemTemplate
>
<
telerik:RadComboBox
ID
=
"uxEmployeeType"
runat
=
"server"
Width
=
"50px"
DataTextField
=
"Name"
DataValueField
=
"ID"
EnableAutomaticLoadOnDemand
=
"true"
OnItemsRequested
=
"uxEmployeeType_ItemsRequested"
>
</
telerik:RadComboBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
And here is my code.
protected
void
uxEmployeeType_ItemsRequested(
object
sender, RadComboBoxItemsRequestedEventArgs e)
{
RadComboBox uxEmployeeType = (RadComboBox)sender;
uxEmployeeType.DataSource = _empTypes.EmployeeTypesMembers;
uxEmployeeType.DataBind();
}
9 Answers, 1 is accepted
I suppose this issue arises because you are setting Automatic Load On Demand.Then you should set a data source id for the DataSourceID property of the RadComboBox. Since you are using ItemsRequested event, then you shouldn't use Automatic Load On Demand, but supply the items to be loaded in the event handler function.For further information check the following demo and help article.
ComboBox / Combo in Grid
Automatic Load On Demand
Thanks,
Shinu
My goal is to keep EnableAutomaticLoadOnDemand = true and then do the data bind on the ItemDataBound event. (Which I tried previously) and I get the same error.
protected
void
uxGrid_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem )
{
// Get the row item
GridDataItem rowItem = (GridDataItem)e.Item;
// Bind the controls in each row
RadComboBox uxEmployeeType = (RadComboBox)rowItem.FindControl(
"uxEmployeeType"
);
uxEmployeeType.DataSource = _empTypes.EmployeeTypesMembers;
uxEmployeeType.DataBind();
}
}
<
telerik:GridTemplateColumn
HeaderText
=
"Employee Type"
DataType
=
"System.String"
>
<
ItemTemplate
>
<
telerik:RadComboBox
ID
=
"uxEmployeeType"
runat
=
"server"
Width
=
"50px"
DataTextField
=
"Name"
DataValueField
=
"ID"
EnableAutomaticLoadOnDemand
=
"true"
>
</
telerik:RadComboBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
When the drop down is clicked I get the error.
If I turn off EnableAutomaticLoadOnDemand it works fine (but, of course, it does not pull the data at the time of the drop down click event).
I am starting to wonder if there is a problem using EnableAutomaticLoadOnDemand when inside of an item template.
Please note that you could not add control into RadGrid ItemTemplate on the ItemDataBound event. This should be definitely done in the ItemCreated event and also if the RadGrid is also dynamically created please ensure that you have create it correctly following the approach from this helps article.
Best wishes,
Maria Ilieva
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Note that if you need to use AutomaticLoadOnDemand you should not use the ItemsRequested event for binding items to the RadComboBox. Actually the ItemsRequested event still fires with automatic Load On Demand. However this event handler could only be used for:
- Add/Remove Items
- Access/Change the ‘Show More Results’ message via the event arguments
- Get/Set the EndOfItems event argument to explicitly stop subsequent ‘show more results/virtual scrolling’ requests
Kind regards,
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
The target 'ctl11$RadGridSearchResult$ctl11_RadGridSearchResult_ctl00_Actplc$Actplc' for the callback could not be found or did not implement ICallbackEventHandler.
public class CreateRadComboTemplate : ITemplate
{
private string tempName;
private int catId;
public CreateRadComboTemplate(string templateName, int catId)
{
this.tempName = templateName;
this.catId = catId;
}
public void InstantiateIn(System.Web.UI.Control container)
{
RadComboBox rcBox = new RadComboBox();
rcBox.ID = this.tempName;
rcBox.ItemsRequested += rcBox_ItemsRequested;
rcBox.EnableAutomaticLoadOnDemand = true;
container.Controls.Add(rcBox);
}
void rcBox_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
//throw new NotImplementedException();
}
}
See the forum post below that should help in fixing the issue:
http://www.telerik.com/community/forums/aspnet-ajax/combobox/dynamically-created-combobox-and-load-on-demand-not-working.aspx
Regards,
Maria Ilieva
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Having tags within the cell value is not supported scenario and it will break the Batch Editing functionality, because the BatchEditingManager expect a particular structure in the ItemTemplate. If you need to have complex ItemTemplate, you will have to handle the get/cell cell/editor values events and handle them manually. Detailed information and example is available in the following help article:
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.